Skip to content

test(inspector): keep the cancellation cases off an ambiguous temporary path - #10026

Closed
XiaoBinGan wants to merge 2 commits into
morluto:mainfrom
XiaoBinGan:fix/inspector-cancellation-temp-path
Closed

XiaoBinGan wants to merge 2 commits into
morluto:mainfrom
XiaoBinGan:fix/inspector-cancellation-temp-path

Conversation

@XiaoBinGan

@XiaoBinGan XiaoBinGan commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

The Inspector cancellation cases depend on where the host puts its temporary directory: with an underscore in TMPDIR the listing returns a result instead of cancelling.

Fixes #9996.

Problem

authorizeRuntimeTargetLocation treats a reported path that contains an underscore as unprovable, because the Inspector URL replaces quotes and backslashes with underscores:

// Node concatenates the pathname, then replaces quotes and backslashes with
// underscores. A remaining underscore cannot prove which pathname was used.
if (process.platform !== "win32" && !/[_"\\]/u.test(reportedPath)) {

That refusal is deliberate and stays. The cases, however, build their fixture with mkdtemp(join(tmpdir(), "rea-inspector-cancel-")), so a host whose temporary root contains an underscore makes the target be excluded before the stat the case aborts on. The case then measures the refusal instead of cancellation and fails with Expected Inspector listing cancellation.

Measured on this checkout:

TMPDIR=/tmp/rea_under_test  1 failed | 4 passed (5)
TMPDIR=/tmp/reaundrtest     5 passed (5)

Approach

Create the fixture under a temporary root that can express a provable path, falling back to /tmp, and skip the cases only when no such root exists. The intent is to keep measuring cancellation rather than the refusal, and to be explicit when the host cannot support the measurement.

Evidence

  • TMPDIR=/tmp/rea_under_test: 1 failed before the change, 5 passed after.
  • Clean temporary root: 5 passed both before and after.
  • Full-project tsc --noEmit, oxfmt --check and oxlint are clean on the changed file.

Unavailable coverage: no Windows run, where the underscore rule does not apply and the guard is inactive. The skip branch was not exercised, because this host has a usable /tmp.

Author readiness

Human owner: @XiaoBinGan

  • 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 11, 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-12T01:16:54.514838Z b37f24e New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa4ceb594d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e079b969a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…ry path

The Inspector URL replaces quotes and backslashes with underscores, so
`authorizeRuntimeTargetLocation` treats a reported path that still contains one
as unprovable and refuses the target. That refusal is deliberate, but it made
these cases depend on where the host puts its temporary directory: with
`TMPDIR` containing an underscore the target is excluded before the stat the
case aborts on, so the listing returns a result instead of cancelling.

Create the fixture under a temporary root that can express a provable path,
falling back to `/tmp`, and skip the cases only when no such root exists, so the
cancellation behaviour is still measured rather than the refusal.

Verified by running the file with `TMPDIR=/tmp/rea_under_test` (1 failed before,
5 passed after) and with a clean root (5 passed both). Full-project typecheck,
`oxfmt --check` and `oxlint` are clean.
@XiaoBinGan
XiaoBinGan force-pushed the fix/inspector-cancellation-temp-path branch from 8e079b9 to 7385621 Compare November 12, 2026 00:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73856215c3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Three review findings on the skip gate.

**Only two cases need a provable root.** The gate skipped all five, but the Electron cancellation
cases reach the same code paths without asserting a resolved path, so they were skipping work they
could do. The two that compare a resolved target — the `V8InspectorProvider` case and the
file-location authorization case — keep the gate; the other three run everywhere.

**Existence is not writability.** The root was chosen by spelling alone, so `/tmp` on a read-only
mount passed and every `mkdtemp` then failed with `EROFS` instead of skipping. The candidate is
probed with `accessSync(root, W_OK)` before it is selected.

**A safe alias can still resolve to an unsafe target.** The spelling was checked in its canonical
form only, so a symlinked `TMPDIR` with a clean name over a target containing a space or `%`
produced an encoded URL. Both the spelling and its canonical form are checked now, and the
spelling is what gets returned, so the fixture keeps the path that worked.

One case still fails on this Windows host — `stops Inspector target authorization after the current
stat settles` — and it fails the same way on `main`; it is not caused by this change.
@XiaoBinGan

Copy link
Copy Markdown
Contributor Author

All three fixed in b37f24ed2.

Only two of the five cases need a provable root. You are right that the Electron cancellation cases do not assert a resolved path — they were skipping work they could do. The V8InspectorProvider case and the file-location authorization case keep the gate; the other three run everywhere now.

Existence is not writability. The root is probed with accessSync(root, W_OK) before it is selected, so /tmp on a read-only mount skips instead of failing every mkdtemp with EROFS.

A safe alias can resolve to an unsafe target. Both the spelling and its canonical form are checked, and the spelling is what gets returned, so a symlinked TMPDIR with a clean name over a target containing a space or % keeps the fixture that worked instead of one whose URL is encoded.

One case still fails on this Windows host (stops Inspector target authorization after the current stat settles); it fails identically on main, so it is not from this change.

@XiaoBinGan

Copy link
Copy Markdown
Contributor Author

Fixed in this push. You are right that the fallback left the verifier's sandbox: the private TMPDIR at scripts/verify-test-temp-hygiene.mjs:27-42 can itself contain _, so selecting global /tmp put the target directories outside the root the verifier scans and removes.

The fix keeps the fallback inside the private root: when tmpdir() and /tmp both fail the spelling test, the case uses tmpdir() rather than a global path, so a fixture that outlives a rejected close() still sits where the verifier will remove it. The writability probe also has to pass, so a read-only mount skips instead of failing on EROFS.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you for this alternative fix for #9996. #10568 (rebase-merged) took the #10118 approach, a dedicated Node discovery temp-directory helper used by the cancellation fixture and its sibling fixtures, so this one is no longer needed. Closing as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@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