-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
process: improve error message for process.cwd() when directory is deleted #57053
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6599712
process: improve error message for process.cwd() when directory is de…
Ankush1oo8 b756922
process: move process.cwd() error handling to native side
Ankush1oo8 a49675f
process: improve error message for process.cwd() when directory is de…
Ankush1oo8 843f44a
process: improve error message for process.cwd() when directory is de…
Ankush1oo8 8ccefc5
Merge branch 'main' into fix-cwd-error-message
Ankush1oo8 5beea2d
process: improve error message for process.cwd() when directory is de…
Ankush1oo8 8d1703a
Merge branch 'fix-cwd-error-message' of https://github.com/Ankush1oo8…
Ankush1oo8 da6f04b
Merge branch 'nodejs:main' into fix-cwd-error-message
Ankush1oo8 26e2e14
Merge branch 'nodejs:main' into fix-cwd-error-message
Ankush1oo8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
// This test verifies that an appropriate error is thrown when the current | ||
// working directory is deleted and process.cwd() is called. | ||
// | ||
// We do this by spawning a forked process and deleting the tmp cwd | ||
// while it is starting up. | ||
|
||
const common = require('../common'); | ||
|
||
const { fork } = require('node:child_process'); | ||
const { rmSync } = require('node:fs'); | ||
const { strictEqual, ok } = require('node:assert'); | ||
const { Buffer } = require('node:buffer'); | ||
|
||
if (process.argv[2] === 'child') { | ||
return; | ||
} | ||
|
||
const tmpdir = require('../common/tmpdir'); | ||
tmpdir.refresh(); | ||
const tmpDir = tmpdir.path; | ||
|
||
const proc = fork(__filename, ['child'], { | ||
cwd: tmpDir, | ||
silent: true, | ||
}); | ||
proc.on('spawn', common.mustCall(() => rmSync(tmpDir, { recursive: true }))); | ||
|
||
proc.on('exit', common.mustCall((code) => { | ||
strictEqual(code, 1); | ||
proc.stderr.toArray().then(common.mustCall((chunks) => { | ||
const buf = Buffer.concat(chunks); | ||
ok(/Current working directory does not exist/.test(buf.toString())); | ||
})); | ||
})); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.