diff options
author | 2023-06-27 23:23:25 +0800 | |
---|---|---|
committer | 2023-06-27 08:23:25 -0700 | |
commit | 1c46d887286350ca102708c7fb8ae090ad88bf31 (patch) | |
tree | 80af07d3c58a90eae799334f69dcbb13918464e5 /src/js/node/util.js | |
parent | d220d9ee5ab7d45c5480ad9a278807eb434f4276 (diff) | |
download | bun-1c46d887286350ca102708c7fb8ae090ad88bf31.tar.gz bun-1c46d887286350ca102708c7fb8ae090ad88bf31.tar.zst bun-1c46d887286350ca102708c7fb8ae090ad88bf31.zip |
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
Diffstat (limited to 'src/js/node/util.js')
-rw-r--r-- | src/js/node/util.js | 5 |
1 files changed, 3 insertions, 2 deletions
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); }, ); } |