node icon indicating copy to clipboard operation
node copied to clipboard

fix: callback with error if SyncWriteStream writeSync failed

Open killagu opened this issue 2 years ago • 8 comments

Fixes: https://github.com/nodejs/node/issues/47948

killagu avatar May 10 '23 11:05 killagu

General observation: the way _write() synchronously invokes cb() is wrong(ish). Node normally follows the iron-clad rule that callbacks are always invoked asynchronously, otherwise you can end up overflowing the stack. Ex.:

function again() {
  stream._write(buf, 'utf8', again); // RangeError: Maximum call stack size exceeded 
}

edit: oh nevermind, this is stream.Writable._write() and the streams code takes care of deferring the callback.

bnoordhuis avatar May 11 '23 00:05 bnoordhuis

CI: https://ci.nodejs.org/job/node-test-pull-request/51767/

nodejs-github-bot avatar May 12 '23 22:05 nodejs-github-bot

ping @bnoordhuis

killagu avatar May 23 '23 14:05 killagu

CI: https://ci.nodejs.org/job/node-test-pull-request/52303/

nodejs-github-bot avatar Jun 21 '23 06:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/52305/

nodejs-github-bot avatar Jun 21 '23 07:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/52321/

nodejs-github-bot avatar Jun 21 '23 16:06 nodejs-github-bot

Some failures on Windows seems related. @killagu can you take a look?

lpinca avatar Jun 21 '23 18:06 lpinca

Of course.

killagu avatar Jun 21 '23 23:06 killagu

Sorry, I'm still looking for a suitable Windows machine to run Node.js compilation and testing. I will provide an update once there is progress.

killagu avatar Jun 25 '23 13:06 killagu

@lpinca I've identified the cause. On the Windows platform, it requires manual release of the fd; otherwise, it will block the process from cleaning up the temporary directory upon exiting. Could you please trigger the CI again? Thank you.

killagu avatar Jun 26 '23 07:06 killagu

CI: https://ci.nodejs.org/job/node-test-pull-request/52484/

nodejs-github-bot avatar Jun 26 '23 07:06 nodejs-github-bot

😅 Force push let the ci down fatal: reference is not a tree: 7bcb45c7a81c3bba6e9ffa96754329c9facd4aa4.

killagu avatar Jun 26 '23 07:06 killagu

CI: https://ci.nodejs.org/job/node-test-pull-request/52485/

nodejs-github-bot avatar Jun 26 '23 08:06 nodejs-github-bot

Also one final request. Can you please change the commit message to something like this?

fs: call the callback with an error if writeSync fails

Thank you.

lpinca avatar Jun 26 '23 10:06 lpinca

It's updated. Thanks very much for review and lots of help.

killagu avatar Jun 26 '23 11:06 killagu

CI: https://ci.nodejs.org/job/node-test-pull-request/52489/

nodejs-github-bot avatar Jun 26 '23 11:06 nodejs-github-bot

Landed in 32eb4921db2993b579bc801399038610c1edb5e8

nodejs-github-bot avatar Jun 26 '23 14:06 nodejs-github-bot