diff options
author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2022-09-07 10:20:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 13:50:30 +0530 |
commit | 199e6f2a386291b2fb3ea061dfc4d6dc10823267 (patch) | |
tree | c27cefc411a247e418a3b48b26a600a2095316bf /core/01_core.js | |
parent | 8bdc3c2bafa9bdfcd6bfaf94b97b960843908ae9 (diff) |
fix(core): opAsync leaks a promise on type error (#15795)
Diffstat (limited to 'core/01_core.js')
-rw-r--r-- | core/01_core.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/01_core.js b/core/01_core.js index fda3e4977..e5e2c9fd5 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -161,9 +161,14 @@ function opAsync(opName, ...args) { const promiseId = nextPromiseId++; let p = setPromise(promiseId); - const maybeError = ops[opName](promiseId, ...args); - // Handle sync error (e.g: error parsing args) - if (maybeError) return unwrapOpResult(maybeError); + try { + ops[opName](promiseId, ...args); + } catch (err) { + // Cleanup the just-created promise + getPromise(promiseId); + // Rethrow the error + throw err; + } p = PromisePrototypeThen(p, unwrapOpResult); if (opCallTracingEnabled) { // Capture a stack trace by creating a new `Error` object. We remove the |