Skip to content

Commit 0b93a9a

Browse files
authored
fix(bridge): instanceof Promise was not giving correct results when run with Jest (#1737)
1 parent bdbb2f1 commit 0b93a9a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/core-bridge/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { isPromise } = require('node:util/types');
12
const { getPrebuiltPath } = require('./common');
23
const typescriptExports = require('./lib/index');
34
const { convertFromNamedError } = require('./lib/errors');
@@ -9,7 +10,7 @@ function wrapErrors(fn) {
910
return (...args) => {
1011
try {
1112
let res = fn(...args);
12-
if (res instanceof Promise) {
13+
if (isPromise(res)) {
1314
return res.catch((e) => {
1415
throw convertFromNamedError(e, false);
1516
});
@@ -55,7 +56,7 @@ if (process.env.TEMPORAL_TRACE_NATIVE_CALLS?.toLowerCase() === 'true') {
5556

5657
let res = fn(...args);
5758

58-
if (res instanceof Promise) {
59+
if (isPromise(res)) {
5960
log(callid, `${fnname}() - received promise`);
6061
return res.then(
6162
(x) => {

0 commit comments

Comments
 (0)