-
Notifications
You must be signed in to change notification settings - Fork 5k
paths: terminate recursive mkdir walk when a confirmed parent still yields ENOENT #36162
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
Open
robobun
wants to merge
13
commits into
main
Choose a base branch
from
farm/ea7dbce8/fix-makepath-spin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+237
−38
Open
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3fcd2bc
paths: terminate make_path_with when a confirmed parent still yields …
robobun 2f6928d
[autofix.ci] apply automated fixes
autofix-ci[bot] dcf8604
trim comments; drop per-test timeout
robobun 662df16
fold make_path_with termination note into existing doc paragraph
robobun 0b03b0d
drop added doc sentence on make_path_with
robobun fbb5034
paths: update MakePathStep::NotFound doc to match new contract
robobun 5376651
install: name the cache directory when it cannot be created
robobun d2a2740
install: only hard-fail on explicitly configured cache dirs; warn+fal…
robobun ddfc4a2
collapse is_explicit doc to one line
robobun 38ee46c
drop dead cache_directory_path=b"" write in implicit-fallback arm
robobun a23676c
test: cover bunfig install.cache.dir spelling for is_explicit
robobun 5456aa1
gate implicit cache-dir fallback warn on log_level != Silent
robobun 2c2c34b
doc: list --cache-dir among is_explicit sources
robobun 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { bunEnv, bunExe, isWindows, tempDir } from "harness"; | ||
| import { symlinkSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
|
|
||
| // A dangling symlink (link itself exists, target does not) makes the | ||
| // recursive cache-dir creation loop oscillate: mkdir(link/child) → ENOENT, | ||
| // mkdir(link) → EEXIST, repeat. The process spun forever at ~50k mkdirat/s | ||
| // with no output. With the fix, the cache-dir open fails and install falls | ||
| // back to node_modules/.cache. | ||
| // | ||
| // Windows is skipped: symlink creation needs Developer Mode / admin, and the | ||
| // fix is in the shared path walk so POSIX coverage is sufficient. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| describe.skipIf(isWindows)("BUN_INSTALL_CACHE_DIR inside a dangling symlink", () => { | ||
|
robobun marked this conversation as resolved.
Outdated
|
||
| test("bun install exits instead of spinning in mkdirat", { timeout: 60_000 }, async () => { | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| using dir = tempDir("cache-dir-dangling", { | ||
| "proj/package.json": JSON.stringify({ | ||
| name: "x", | ||
| version: "1.0.0", | ||
| dependencies: { "any-pkg": "1.0.0" }, | ||
| }), | ||
| }); | ||
| const root = String(dir); | ||
| symlinkSync(join(root, "does-not-exist"), join(root, "dangling")); | ||
|
|
||
| await using proc = Bun.spawn({ | ||
| cmd: [bunExe(), "install"], | ||
| cwd: join(root, "proj"), | ||
| env: { | ||
| ...bunEnv, | ||
| BUN_INSTALL_CACHE_DIR: join(root, "dangling", "cache"), | ||
| BUN_CONFIG_REGISTRY: "http://127.0.0.1:1/", | ||
| }, | ||
| stdout: "pipe", | ||
| stderr: "pipe", | ||
| timeout: 15_000, | ||
| }); | ||
| const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); | ||
|
|
||
| // On hang, Bun.spawn's timeout fires and the child is killed with a | ||
| // signal. With the fix, bun exits on its own (registry is unreachable). | ||
| expect({ signalCode: proc.signalCode, stdout, stderr }).toMatchObject({ | ||
| signalCode: null, | ||
| }); | ||
| expect(stderr).toContain("error"); | ||
| expect(exitCode).not.toBe(0); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
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.