mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Do not double-reject errors
Calling .then here creates a new promise. One that is not returned and generating a rejection within that promise can lead to unhandledRejection events being inappropriately raised. As such, don't declare unneeded variables.
This commit is contained in:
parent
8f69678a88
commit
3606589ff2
@ -36,9 +36,9 @@ class PromiseTracker {
|
||||
const promise = prms;
|
||||
promise.waitList = `${variable} waited on by: ${specifier}`;
|
||||
promise.state = 'pending';
|
||||
promise.then(
|
||||
(value) => { promise.state = 'resolved'; return Promise.resolve(value); },
|
||||
(error) => { promise.state = 'rejected'; return Promise.reject(error); });
|
||||
promise.then( // creates a promise with the following effects but that we otherwise ignore
|
||||
() => { promise.state = 'resolved'; },
|
||||
() => { promise.state = 'rejected'; });
|
||||
this.promiseList.push(promise);
|
||||
this.promiseMap[variable] = promise;
|
||||
return promise;
|
||||
@ -393,7 +393,7 @@ class Variables {
|
||||
].join('');
|
||||
ret = BbPromise.reject(new this.serverless.classes.Error(errorMessage));
|
||||
}
|
||||
this.tracker.add(variableString, ret, propertyString);
|
||||
ret = this.tracker.add(variableString, ret, propertyString);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user