mirror of
https://github.com/denoland/deno.git
synced 2025-01-05 13:59:01 -05:00
fix(core): opAsync leaks a promise on type error (#15795)
This commit is contained in:
parent
dd428d1dc8
commit
42564b6c37
1 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue