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

fs.cp throws error with message 'cp returned undefined' #41104

Closed
everett1992 opened this issue Dec 7, 2021 · 0 comments · Fixed by #41106
Closed

fs.cp throws error with message 'cp returned undefined' #41104

everett1992 opened this issue Dec 7, 2021 · 0 comments · Fixed by #41106
Labels
fs Issues and PRs related to the fs subsystem / file system.

Comments

@everett1992
Copy link
Contributor

Version

17.2.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

$ touch example
$ node -e "require('fs').cp('example', 'example', console.log)"

This throws as expected ERR_FS_CP_EINVAL.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL (src and dest cannot be the same) example
                                                                 ^^^^^^

What do you see instead?

SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned undefined (src and dest cannot be the same) example
                                                                 ^^^^^^^^^

Additional information

I'm not sure if this is a bug or intentional behavior but seeing undefined in an error message was unexpected.

throw new ERR_FS_CP_EINVAL({
message: 'src and dest cannot be the same',
path: dest,
syscall: 'cp',
errno: EINVAL,
});

node/lib/internal/errors.js

Lines 225 to 226 in c8a0404

let message = `${prefix}: ${context.syscall} returned ` +
`${context.code} (${context.message})`;

Based on the code should new ERR_FS_CP_EINVAL pass code: EINVAL, or should SystemError use context.code ?? context.errno, or is this the intended behavior?

aduh95 added a commit to aduh95/node that referenced this issue Dec 7, 2021
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: nodejs#41104
@Mesteery Mesteery added the fs Issues and PRs related to the fs subsystem / file system. label Dec 7, 2021
nodejs-github-bot pushed a commit that referenced this issue Dec 10, 2021
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: #41104

PR-URL: #41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this issue Dec 13, 2021
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: #41104

PR-URL: #41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this issue Dec 14, 2021
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: #41104

PR-URL: #41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 31, 2022
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: #41104

PR-URL: #41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 31, 2022
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: #41104

PR-URL: #41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Linkgoron pushed a commit to Linkgoron/node that referenced this issue Jan 31, 2022
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: nodejs#41104

PR-URL: nodejs#41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this issue Feb 1, 2022
The context passed into this error must have `.code`, `.syscall` and
`.message`.

Fixes: #41104

PR-URL: #41106
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants