mirror of
https://github.com/denoland/deno.git
synced 2025-01-06 22:35:51 -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) {
|
function opAsync(opName, ...args) {
|
||||||
const promiseId = nextPromiseId++;
|
const promiseId = nextPromiseId++;
|
||||||
let p = setPromise(promiseId);
|
let p = setPromise(promiseId);
|
||||||
const maybeError = ops[opName](promiseId, ...args);
|
try {
|
||||||
// Handle sync error (e.g: error parsing args)
|
ops[opName](promiseId, ...args);
|
||||||
if (maybeError) return unwrapOpResult(maybeError);
|
} catch (err) {
|
||||||
|
// Cleanup the just-created promise
|
||||||
|
getPromise(promiseId);
|
||||||
|
// Rethrow the error
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
p = PromisePrototypeThen(p, unwrapOpResult);
|
p = PromisePrototypeThen(p, unwrapOpResult);
|
||||||
if (opCallTracingEnabled) {
|
if (opCallTracingEnabled) {
|
||||||
// Capture a stack trace by creating a new `Error` object. We remove the
|
// Capture a stack trace by creating a new `Error` object. We remove the
|
||||||
|
|
Loading…
Reference in a new issue