-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: use assert in fsCall argument checking #38519
Conversation
The throw can be triggered like this: import { open } from 'fs/promises'
const handle = await open(new URL(import.meta.url))
handle.read.call({}) |
OK, get it. Also noticed that the One more question, what if we change all these prototype methods, such as |
Alternatively this could be changed to an |
In the user perspective, it's not an arguemnt type error. Replace it with an `assert` expression.
+1. In the user perspective, it's not an argument type error. Replaced it with an |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
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.
Could you also update the PR title?
Updated |
Landed in 8231cc4 |
In the user perspective, it's not an arguemnt type error. Replace it with an `assert` expression. PR-URL: #38519 Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/internal/fs/promises.js.html#L268 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
In the user perspective, it's not an arguemnt type error. Replace it with an `assert` expression. PR-URL: #38519 Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/internal/fs/promises.js.html#L268 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
It seems to be a piece of dead code and could be safely removed1. ThefsCall
function is only used within theFileHandle
prototype methods2. The second argument of every call isthis
, which ensures it's an instance ofFileHandle
Updated, see #38519 (comment)
Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/internal/fs/promises.js.html#L268