-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
fs: prevent multiple invocations of callback in Dir class #58430
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58430 +/- ##
==========================================
+ Coverage 90.18% 90.20% +0.02%
==========================================
Files 629 635 +6
Lines 186657 187225 +568
Branches 36658 36761 +103
==========================================
+ Hits 168328 168891 +563
+ Misses 11126 11095 -31
- Partials 7203 7239 +36
🚀 New features to boost your workflow:
|
3307cf8
to
2fdc8ee
Compare
We definitely do need a test for this: to ensure that the bug is fixed, and to ensure that it doesn't appear again after changes in the future. |
2fdc8ee
to
4a99cc2
Compare
@LiviaMedeiros have added the test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Unfortunately, it might be a bit harder to fix this issue.
// A robust fs.Dir should catch this internally and not call this callback again. | ||
throw new Error('Simulated user error in dir.read callback'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct: fs.Dir should not catch and suppress errors from user-provided callback, this error must bubble up.
The test shows that the simulated error disappears on its way, probably due to how FSReqCallback
's oncomplete
is handled on C++ side.
We might need to either investigate the cause and make errors inside oncomplete
be thrown, or detach the callback call from it (e.g. using queueMicrotask
).
Refs: #58419
I am only implementing this for the Dir class because I can create a case where it produces an error.