From 98773c6bea317fe110d2bd63ba118c84ab600405 Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Thu, 3 Jul 2025 12:17:39 -0400 Subject: [PATCH] fix(bridge): `instanceof Promise` was not giving correct results when run with Jest --- packages/core-bridge/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core-bridge/index.js b/packages/core-bridge/index.js index ebd8c0ff2..211283c01 100644 --- a/packages/core-bridge/index.js +++ b/packages/core-bridge/index.js @@ -1,3 +1,4 @@ +const { isPromise } = require('node:util/types'); const { getPrebuiltPath } = require('./common'); const typescriptExports = require('./lib/index'); const { convertFromNamedError } = require('./lib/errors'); @@ -9,7 +10,7 @@ function wrapErrors(fn) { return (...args) => { try { let res = fn(...args); - if (res instanceof Promise) { + if (isPromise(res)) { return res.catch((e) => { throw convertFromNamedError(e, false); }); @@ -55,7 +56,7 @@ if (process.env.TEMPORAL_TRACE_NATIVE_CALLS?.toLowerCase() === 'true') { let res = fn(...args); - if (res instanceof Promise) { + if (isPromise(res)) { log(callid, `${fnname}() - received promise`); return res.then( (x) => {