1
0
Fork 0
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:
Aapo Alasuutari 2022-09-07 10:20:30 +02:00 committed by Yoshiya Hinosawa
parent dd428d1dc8
commit 42564b6c37
No known key found for this signature in database
GPG key ID: 0E8BFAA8A5B4E92B

View file

@ -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