Repository navigation
refactor(inspector): own the Node discovery path rule in one module - #10680
Conversation
Node Inspector discovery reports a target as `file://` plus the pathname, with quotes and backslashes replaced by underscores. Whether such a pathname is identifiable was decided twice: inline in authorizeRuntimeTargetLocation and again as NODE_DISCOVERY_AMBIGUOUS in the createNodeDiscoveryTempDirectory fixture. The copies could drift, and the fixture could not import the product rule without loading JavaScriptRuntimeScope and its Electron file-scope chain. Move the rule to src/inspector/nodeDiscoveryPath.ts, a module with no imports, and use it from both places. Behavior is unchanged. A unit test covers the Windows branch, which Linux CI cannot reach through the boundary tests. Validation: nodeDiscoveryPath and cancellation tests 12/12; javascriptRuntimeTargetLocations and javascriptRuntimeObservation 42/42 with TMPDIR containing an underscore (exercises the /tmp fallback); check:fast passes. Refs morluto#9996
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Low impact] The PR appears safe to merge; the shared rule preserves existing behavior. SummaryThis PR gives
No actionable issues were found. No previous review threads were supplied. The previous and current commits have different merge bases with the target, so this review covered the full PR. Tests were not rerun. Whether another PR supersedes this one could not be checked because GitHub access required authentication. Reviews (6) · Last reviewed commit: "Merge morluto/rea main into node-discove..." · Reviewed by Greptile |
Main now reports cancellation through cancelledBy and counts ambient process.platform reads against a baseline that can only shrink. The lossless-path rule takes the platform as a required parameter, so the module still imports nothing and reads no host state. The one existing process.platform read stays in JavaScriptRuntimeScope, where main already counts it, and the fixture passes the platform itself.
Main now reads the host through HOST_PLATFORM in JavaScriptRuntimeScope and checks the same lossless-path rule inline (not Windows, absolute, no underscore, quote or backslash). The merge keeps that rule in isLosslessNodeDiscoveryPath, which already requires the absolute path, and passes HOST_PLATFORM.platform.
gensokyo-dev
left a comment
There was a problem hiding this comment.
Verified: an equivalent refactor. The predicate matches the removed inline condition and the fixture's former regex, and the inspector scope tests and typecheck pass. Thanks.
Summary
Refs #9996. Two places decided whether Node Inspector discovery identifies a pathname exactly:
authorizeRuntimeTargetLocation;NODE_DISCOVERY_AMBIGUOUSin thecreateNodeDiscoveryTempDirectoryfixture (583bb47, f35b6a7).This moves the rule into one module with no imports and uses it in both places. Behavior is unchanged.
Change and scope
src/inspector/nodeDiscoveryPath.ts:isLosslessNodeDiscoveryPath(path, platform = process.platform). It returns true only for a non-Windows absolute path that contains no_,"or\.JavaScriptRuntimeScope.tsuses it in place of the inline regex and platform check.tests/fixtures/temporaryDirectory.tsuses it in place of its duplicated regex. The module imports nothing, so the shared fixture no longer has to loadJavaScriptRuntimeScopeand its Electron file-scope chain.nodeDiscoveryPath.test.tscovers the Windows branch, which Linux CI cannot reach through the boundary tests.Evidence and regression coverage
src/inspector/nodeDiscoveryPath.test.tsandJavaScriptRuntimeScope.cancellation.test.ts: 12 passed.javascriptRuntimeTargetLocationsandjavascriptRuntimeObservationwithTMPDIRcontaining_: 42 passed. This exercises the/tmpfallback.Validation performed
npm run test:local -- src/inspector/nodeDiscoveryPath.test.ts src/inspector/JavaScriptRuntimeScope.cancellation.test.ts: 12 passed.TMPDIR=…/bad_root npm run test:focused -- tests/boundary/inspector/javascriptRuntimeTargetLocations.test.ts tests/boundary/inspector/javascriptRuntimeObservation.test.ts: 42 passed.npm run check:fastpassed.Author readiness
Human owner: @Davmunrey
Before merge
type(scope): outcome.