-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
fs: add signal option to fs.stat() #57775
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 #57775 +/- ##
========================================
Coverage 90.23% 90.24%
========================================
Files 630 630
Lines 185518 185707 +189
Branches 36369 36412 +43
========================================
+ Hits 167401 167587 +186
+ Misses 11005 10999 -6
- Partials 7112 7121 +9
🚀 New features to boost your workflow:
|
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.
The commit message after subsystem should start with imperative verb and probably be more specific, maybe something like fs: add signal option to fs.stat()
?
options.signal.addEventListener('abort', onAbort, { once: true }); | ||
} | ||
|
||
req.oncomplete = (err, stats) => { |
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.
Non-blocking concern, since oncomplete
is our happy path here: this code paired with makeStatsCallback
essentially wraps the callback twice. Maybe we can somehow avoid this, even at the cost of making abort paths slower and uglier.
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.
I wonder if you think this method is good?
To avoid wrapping the callback twice during the happy path, I do not wrap the callback at the beginning, I wrap it with a one-time makeStatsCallback in oncomplete after the abort check. When the abort condition occurs, I call the normal callback directly.
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 perfect (we still validate callback twice and wrap twice inside the happy path), but I don't see perfect solution without rewriting all functions that use makeStatsCallback
in the same way.
A good compromise for now would be adding a TODO comment here and optimizing it later.
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.
Can I leave it as it is now and add todo?
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.
I try added to this line 28bc2c3
291c8a6
to
911f8da
Compare
thank you very much, I will be more careful with this, sometimes I make the wrong sentence 🙏 |
f9b0d0d
to
9fcffb4
Compare
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.
Doesn't necessarily have to be in scope of this PR, but i think we'll also need signal
option for Sync and Promises API of this function, and also for the lstat
version; ideally within same semver-minor release so there's no discrepancy between these functions.
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.
Test is writing a temporary file in the cwd. It should use common
API instead
@mertcanaltin ... can you please remove the merge commit from this and use rebase instead to catch it up? |
Co-authored-by: Livia Medeiros <[email protected]>
171a72d
to
99ec837
Compare
thank you I used rebase |
add signal option to fs.stat() for #57751