From 1c46d887286350ca102708c7fb8ae090ad88bf31 Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Tue, 27 Jun 2023 23:23:25 +0800 Subject: Fix `node:util.callbackify` (#3428) * remove the incorrect parameters Close: https://github.com/oven-sh/bun/issues/3424 * fix error code * add callbackify tests * fix function type * ensure `done` is called when error occurred --- src/js/node/util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/js/node/util.js') diff --git a/src/js/node/util.js b/src/js/node/util.js index 346f88ffb..8f20a4bc1 100644 --- a/src/js/node/util.js +++ b/src/js/node/util.js @@ -518,6 +518,7 @@ function callbackifyOnRejected(reason, cb) { if (!reason) { var newReason = new Error("Promise was rejected with a falsy value"); newReason.reason = reason; + newReason.code = "ERR_FALSY_VALUE_REJECTION"; reason = newReason; } return cb(reason); @@ -538,10 +539,10 @@ function callbackify(original) { }; original.apply(this, args).then( function (ret) { - process.nextTick(cb, null, null, ret); + process.nextTick(cb, null, ret); }, function (rej) { - process.nextTick(callbackifyOnRejected, null, rej, cb); + process.nextTick(callbackifyOnRejected, rej, cb); }, ); } -- cgit v1.2.3