fix: callback with error if SyncWriteStream writeSync failed
Fixes: https://github.com/nodejs/node/issues/47948
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.
CI: https://ci.nodejs.org/job/node-test-pull-request/51767/
ping @bnoordhuis
CI: https://ci.nodejs.org/job/node-test-pull-request/52303/
CI: https://ci.nodejs.org/job/node-test-pull-request/52305/
CI: https://ci.nodejs.org/job/node-test-pull-request/52321/
Some failures on Windows seems related. @killagu can you take a look?
Of course.
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.
@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.
CI: https://ci.nodejs.org/job/node-test-pull-request/52484/
😅 Force push let the ci down fatal: reference is not a tree: 7bcb45c7a81c3bba6e9ffa96754329c9facd4aa4.
CI: https://ci.nodejs.org/job/node-test-pull-request/52485/
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.
It's updated. Thanks very much for review and lots of help.
CI: https://ci.nodejs.org/job/node-test-pull-request/52489/
Landed in 32eb4921db2993b579bc801399038610c1edb5e8