Skip to content

test(inspector): normalize isolated dir tmpdir with underscores for the cancellation fixture - #10456

Closed
LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/tmppath-underscore-9996
Closed

LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/tmppath-underscore-9996

Conversation

@LexLuthorPrimero

@LexLuthorPrimero LexLuthorPrimero commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #9996.

The Inspector cancellation regression test creates its file under tmpdir(), which inherits the host's TMPDIR (e.g. bad_root). Node's lossy discovery metadata concatenates the pathname and replaces " and \ with underscores, so any remaining _ on POSIX paths marks the path unresolvable and the location guard intentionally refuses to stat it — the provider then finishes without the abort hook firing, and the test hangs or misses its cancellation assertion.

Change and scope

  • src/inspector/JavaScriptRuntimeScope.cancellation.test.ts — derive the fixture's working base by stripping underscores from tmpdir() (replace(/_/g, "-")), recreating the directory when the sanitized spelling differs, and use it unchanged otherwise. Behavior unchanged when TMPDIR contains no underscores; deterministic when it does. No production code is changed.

Evidence and regression coverage

  • npm run test:local -- src/inspector/JavaScriptRuntimeScope.cancellation.test.ts on a temp root with an underscore (TMPDIR=/tmp/opencode/rea_bad_root) — 5 passed.
  • npm run test:local -- src/inspector/JavaScriptRuntimeScope.cancellation.test.ts on the default TMPDIR — 5 passed.
  • npm run typecheck — passed. npm run format:check — passed. npm run lint — passed.

Remaining proof gaps

  • The underscore-tmpdir case is tested only under the Linux host here; the dist-built CLI package ([email protected]) was not re-executed under macOS.
  • We did not change the intentional uncertainty guard in JavaScriptRuntimeScope.ts per the issue's explicit guidance.

Compatibility, safety, and release

  • Breaking changes: none. Test fixture change only.

Author readiness

Human owner: @LexLuthorPrimero

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T02:57:59.111106Z 58839ce PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with two previously reported, non-blocking fixture concerns still open.

Findings

  1. P2 Renamed parents may be unwritable ▶
  2. P2 Created parents are never removed ▶
Fix with agent prompt
### Issue 1
src/inspector/JavaScriptRuntimeScope.cancellation.test.ts:115-117
If `TMPDIR=/home/test_user/tmp` and the developer cannot write to `/home`, this helper changes the base to `/home/test-user/tmp` and fails when creating it. All five tests then fail during setup, leaving the underscore-path fix incomplete. Choose an existing writable, underscore-free base rather than assuming the renamed path is writable.

### Issue 2
src/inspector/JavaScriptRuntimeScope.cancellation.test.ts:undefined-117
The directory created by `mkdir` is never registered for cleanup. `roots` contains only the children created by `mkdtemp`, so tests leave the sanitized base and any newly created parents behind. Track which directories this helper creates and remove only those owned directories after their fixtures are gone.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Changes the cancellation test fixture to replace underscores in its temporary base path before creating files.

  • The Inspector cancellation test uses a temporary path without underscores when needed.

Reviews (2) · Last reviewed commit: "test(inspector): normalize isolated dir ..." · Reviewed by Greptile

Comment on lines +115 to +117
const sanitized = tmpdir().replace(/_/g, "-");
if (sanitized === tmpdir()) return tmpdir();
await mkdir(sanitized, { recursive: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Renamed parents may be unwritable

If TMPDIR=/home/test_user/tmp and the developer cannot write to /home, this helper changes the base to /home/test-user/tmp and fails when creating it. All five tests then fail during setup, leaving the underscore-path fix incomplete. Choose an existing writable, underscore-free base rather than assuming the renamed path is writable.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/inspector/JavaScriptRuntimeScope.cancellation.test.ts
Line: 115-117

Comment:
**Renamed parents may be unwritable**

If `TMPDIR=/home/test_user/tmp` and the developer cannot write to `/home`, this helper changes the base to `/home/test-user/tmp` and fails when creating it. All five tests then fail during setup, leaving the underscore-path fix incomplete. Choose an existing writable, underscore-free base rather than assuming the renamed path is writable.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

// without underscores rather than changing that intentional behavior.
const sanitized = tmpdir().replace(/_/g, "-");
if (sanitized === tmpdir()) return tmpdir();
await mkdir(sanitized, { recursive: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Created parents are never removed

The directory created by mkdir is never registered for cleanup. roots contains only the children created by mkdtemp, so tests leave the sanitized base and any newly created parents behind. Track which directories this helper creates and remove only those owned directories after their fixtures are gone.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/inspector/JavaScriptRuntimeScope.cancellation.test.ts
Line: 117

Comment:
**Created parents are never removed**

The directory created by `mkdir` is never registered for cleanup. `roots` contains only the children created by `mkdtemp`, so tests leave the sanitized base and any newly created parents behind. Track which directories this helper creates and remove only those owned directories after their fixtures are gone.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you. This creates an underscore-free sibling of tmpdir() with mkdir -p and never cleans it up. #10118 instead picks an owned canonical temporary root through the shared fixture helper, so we're closing this in favor of #10118.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

For the record: #9996 was fixed by #10568 (rebase-merged) using the #10118 dedicated-helper approach rather than the system-tmpdir variant here. Thank you for the alternative.

@morluto morluto added the area: tests Test suite and verification label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Inspector cancellation test fails when TMPDIR contains an underscore

3 participants