Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: callback with error if SyncWriteStream writeSync failed #47949

Merged
merged 1 commit into from
Jun 26, 2023

Conversation

killagu
Copy link
Contributor

@killagu killagu commented May 10, 2023

Fixes: #47948

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels May 10, 2023
@bnoordhuis
Copy link
Member

bnoordhuis commented May 11, 2023

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.

@killagu killagu force-pushed the fix/stdout_error branch 3 times, most recently from 3726f80 to 7c8c81f Compare May 11, 2023 07:39
@kvakil kvakil added the request-ci Add this label to start a Jenkins CI on a PR. label May 12, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 12, 2023
@nodejs-github-bot
Copy link
Collaborator

@killagu
Copy link
Contributor Author

killagu commented May 23, 2023

ping @bnoordhuis

@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 21, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 21, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@lpinca
Copy link
Member

lpinca commented Jun 21, 2023

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

@killagu
Copy link
Contributor Author

killagu commented Jun 21, 2023

Of course.

@killagu
Copy link
Contributor Author

killagu commented Jun 25, 2023

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 lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 26, 2023
@killagu
Copy link
Contributor Author

killagu commented Jun 26, 2023

@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.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 26, 2023
@nodejs-github-bot
Copy link
Collaborator

@killagu
Copy link
Contributor Author

killagu commented Jun 26, 2023

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

@nodejs-github-bot
Copy link
Collaborator

lib/internal/fs/sync_write_stream.js Outdated Show resolved Hide resolved
@lpinca
Copy link
Member

lpinca commented Jun 26, 2023

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.

Catch SyncWriteStream write file error.

Fixes: nodejs#47948
Signed-off-by: killagu <[email protected]>
@killagu
Copy link
Contributor Author

killagu commented Jun 26, 2023

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

@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 26, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 26, 2023
@nodejs-github-bot
Copy link
Collaborator

@lpinca lpinca added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 26, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 26, 2023
@nodejs-github-bot nodejs-github-bot merged commit 32eb492 into nodejs:main Jun 26, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 32eb492

RafaelGSS pushed a commit that referenced this pull request Jul 3, 2023
Catch SyncWriteStream write file error.

Fixes: #47948
Signed-off-by: killagu <[email protected]>
PR-URL: #47949
Reviewed-By: Luigi Pinca <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Jul 3, 2023
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Catch SyncWriteStream write file error.

Fixes: nodejs#47948
Signed-off-by: killagu <[email protected]>
PR-URL: nodejs#47949
Reviewed-By: Luigi Pinca <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Catch SyncWriteStream write file error.

Fixes: nodejs#47948
Signed-off-by: killagu <[email protected]>
PR-URL: nodejs#47949
Reviewed-By: Luigi Pinca <[email protected]>
ruyadorno pushed a commit that referenced this pull request Sep 10, 2023
Catch SyncWriteStream write file error.

Fixes: #47948
Signed-off-by: killagu <[email protected]>
PR-URL: #47949
Reviewed-By: Luigi Pinca <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Sep 10, 2023
ruyadorno pushed a commit that referenced this pull request Sep 13, 2023
Catch SyncWriteStream write file error.

Fixes: #47948
Signed-off-by: killagu <[email protected]>
PR-URL: #47949
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

process.stdout may memleak if write file failed.
5 participants