From 3de2ea519ec01817b45cf5e30a81fc38e4b7670e Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Thu, 12 Jan 2023 17:20:36 +0000 Subject: [PATCH] fixup! bad(Swingset): Releasing a constrained Zalgo on syscall replay Address feedback: better isThenable check --- packages/SwingSet/src/kernel/vat-loader/async-helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/SwingSet/src/kernel/vat-loader/async-helper.js b/packages/SwingSet/src/kernel/vat-loader/async-helper.js index 709899c40197..281fa6802fa2 100644 --- a/packages/SwingSet/src/kernel/vat-loader/async-helper.js +++ b/packages/SwingSet/src/kernel/vat-loader/async-helper.js @@ -19,7 +19,7 @@ * @returns {T extends PromiseLike ? Promise> : R} */ export function maybeAsync(v, handle) { - if (typeof v === 'object' && v !== null && 'then' in v) { + if (Object(v) === v && typeof v.then === 'function') { return Promise.resolve(v).then(handle); } else { return handle(v); @@ -37,7 +37,7 @@ export function ensureSync(fn) { // eslint-disable-next-line func-names return function (...args) { const result = Reflect.apply(fn, this, args); - if (typeof result === 'object' && result !== null && 'then' in result) { + if (Object(result) === result && typeof result.then === 'function') { throw new Error('Unexpected async result'); } else { return result;