From 0b85c22ec72ccd7b9a9bae565f65f7d8512095cc Mon Sep 17 00:00:00 2001 From: Wil Wilsman Date: Fri, 29 Jul 2022 15:06:14 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Use=20then=20instead=20of=20fina?= =?UTF-8?q?lly=20for=20promises=20with=20the=20yieldTo=20util=20(#1016)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some versions of V8 complain about promise rejections if there is no detected catch handler. Even though we await on these promises and allow them to reject asynchronously, the error can still surface as "PromiseRejectionHandledWarning: Promise rejection was handled asynchronously." This is fixed by using then with a catch handler instead of a single finally. The promise reference no longer needs to be updated since it would cause issues to be swallowed. --- packages/core/src/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/utils.js b/packages/core/src/utils.js index bb7263222..19662df68 100644 --- a/packages/core/src/utils.js +++ b/packages/core/src/utils.js @@ -100,7 +100,7 @@ export class AbortError extends Error { // An async generator that yields after every event loop until the promise settles export async function* yieldTo(subject) { let pending = typeof subject?.finally === 'function'; - if (pending) subject = subject.finally(() => (pending = false)); + if (pending) subject.then(() => (pending = false), () => (pending = false)); /* eslint-disable-next-line no-unmodified-loop-condition */ while (pending) yield new Promise(r => setImmediate(r)); return isGenerator(subject) ? yield* subject : await subject;