fix(devtools-bundler-core): open source files outside cwd and end bad open-source requests #541
"Go to Source" opens a wrong path when the source file is outside the current working directory, for example in a monorepo package or when Vite runs from another directory. This PR makes the open-source handler keep the absolute path of such files. It also answers 400 for a bad source, so the request no longer stays pending.
🎯 Changes#
addSourceToJsxstripsprocess.cwd()from the module path. A file outside cwd keeps its absolute path, and the handler then added cwd again:/repo/apps/web/repo/packages/pkg/src/panel.tsx.- The handler now uses the absolute path when the cwd-relative file does not exist and the absolute file does. Files inside cwd resolve as before.
- A missing or malformed
sourcereturned withoutres.end(), so the request stayed pending until the browser timed out (the server part of #451). It now answers400. - The Vite and Rspack plugins both use this shared handler.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Testing#
Commands run
vitest runinpackages/devtools-bundler-core: 200 tests pass. The 3 new and updated tests failed before the fix.eslint,tsc, andprettier --checkon the changed files: pass.- I did not run the full
pnpm test:pr.
Manual test
- In a monorepo, run Vite from
apps/weband render a component frompackages/pkg. Or use the StackBlitz repro in #281. - Before this fix: click-to-source on that component sends a path with cwd added twice, and the editor opens an empty file.
- After this fix: the editor opens
packages/pkg/src/...at the right line. - Open
/__tsd/open-source?source=in the browser. Before: pending forever. After:400.
How this PR makes testing easy
Unit tests in utils.test.ts cover a file outside cwd (the repo root package.json) and the 400 answers.
Linked issues#
Fixes #281
Fixes #176
Refs #451 (the client part of #451 was fixed in @tanstack/devtools@0.12.3)
Risk / rollback#
Low. If both the cwd-relative path and the absolute path exist, the cwd-relative path wins, as before. To undo, revert this PR.
🤖 Generated with Claude Code
Summary by CodeRabbit#
- Bug Fixes
- “Go to Source” now handles files outside the current working directory correctly.
- Requests with missing or invalid source paths now receive an HTTP 400 response instead of remaining pending.
- 1
View your CI Pipeline Execution ↗ for commit 32e150a8e7ecb447a50d5e6e8e57472e91500268
Command Status Duration Result nx run-many --target=test:e2e --parallel=1 --pr...✅ Succeeded 1m 13s View ↗ nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded 58s View ↗ nx run-many --targets=build --exclude=examples/...✅ Succeeded 8s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-02 13:17:45UTCMore templates
- @tanstack/devtools-example-angular-a11y-devtools
- @tanstack/devtools-example-angular-basic
- @tanstack/devtools-example-angular-panel
- ssr
- @tanstack/devtools-example-angular-with-devtools
- @tanstack/devtools-example-preact-basic
- @tanstack/devtools-custom-devtools-preact
- @tanstack/solid-devtools-a11y-example
- @tanstack/devtools-example-solid-basic
- @tanstack/devtools-example-devtools-ui
- @tanstack/devtools-example-solid-start
- @tanstack/query-example-vue-basic
- @tanstack/react-devtools-a11y-example
- @tanstack/devtools-example-react-basic
- start-repro
- @tanstack/devtools-custom-devtools
- tanstack-start-example-counter
- @tanstack/devtools-example-react-https
- start
- start-cloudflare
- start-nitro
- @tanstack/devtools-example-react-time-travel
@tanstack/angular-devtools
npm i https://pkg.pr.new/@tanstack/angular-devtools@541@tanstack/devtools
npm i https://pkg.pr.new/@tanstack/devtools@541@tanstack/devtools-a11y
npm i https://pkg.pr.new/@tanstack/devtools-a11y@541@tanstack/devtools-bundler-core
npm i https://pkg.pr.new/@tanstack/devtools-bundler-core@541@tanstack/devtools-client
npm i https://pkg.pr.new/@tanstack/devtools-client@541@tanstack/devtools-rspack
npm i https://pkg.pr.new/@tanstack/devtools-rspack@541@tanstack/devtools-ui
npm i https://pkg.pr.new/@tanstack/devtools-ui@541@tanstack/devtools-utils
npm i https://pkg.pr.new/@tanstack/devtools-utils@541@tanstack/devtools-vite
npm i https://pkg.pr.new/@tanstack/devtools-vite@541@tanstack/devtools-webmcp
npm i https://pkg.pr.new/@tanstack/devtools-webmcp@541@tanstack/devtools-event-bus
npm i https://pkg.pr.new/@tanstack/devtools-event-bus@541@tanstack/devtools-event-client
npm i https://pkg.pr.new/@tanstack/devtools-event-client@541@tanstack/preact-devtools
npm i https://pkg.pr.new/@tanstack/preact-devtools@541@tanstack/react-devtools
npm i https://pkg.pr.new/@tanstack/react-devtools@541@tanstack/solid-devtools
npm i https://pkg.pr.new/@tanstack/solid-devtools@541@tanstack/svelte-devtools
npm i https://pkg.pr.new/@tanstack/svelte-devtools@541@tanstack/vue-devtools
npm i https://pkg.pr.new/@tanstack/vue-devtools@541commit:
32e150aAlemTuzlak merged thisdf1464c
AlemTuzlak closed this
🎉 This PR has been released!
Thank you for your contribution!
Sign in to join this conversation.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: TanStack/devtools/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
e3cd093d-ff24-48b9-b20c-0e76ac59ce84📥 Commits
Reviewing files that changed from the base of the PR and between afa01fec1751308eb5f60e737e408f2fc34e669a and 32e150a8e7ecb447a50d5e6e8e57472e91500268.
📒 Files selected for processing (3)
.changeset/open-source-outside-cwd.mdpackages/devtools-bundler-core/src/utils.test.tspackages/devtools-bundler-core/src/utils.tsIncluded review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
📝 Walkthrough
Walkthrough#
The handler now preserves applicable source paths outside the current working directory and returns a completed HTTP 400 response when the
sourcevalue is missing or malformed.Changes#
Source request handling
packages/devtools-bundler-core/src/utils.ts,packages/devtools-bundler-core/src/utils.test.tssourcevalues now produce a 400 response that ends. Tests verify that no callback ornext()call occurs.packages/devtools-bundler-core/src/utils.ts,packages/devtools-bundler-core/src/utils.test.ts,.changeset/open-source-outside-cwd.mdresolveSourceFile. A test verifies that an absolute path outside the current working directory is preserved. The changeset records patch releases for three packages.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: ⚪ Minimal · up to
32e15The changes are mergeable. A pre-existing click-to-code edge case remains when an external directory’s name begins with the working directory’s name.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
32e15The fix supports source files outside the working directory and completes invalid requests. The previous implementation already allowed paths outside that directory, so the change does not establish a new maximum file-access scope. Risk remains dependent on who can reach the development server and the controls surrounding it.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)#
sourcerequests is not connected to the coding objectives in [#281] or [#176]. Those issues require correct source-path resolution. The PR adds imp…sourcevalidation and its tests, or link an active issue that requires this behavior.✅ Passed checks (3 passed)
resolveSourceFilelogic addresses both path issues [#281] [#176]. It uses the cwd-relative path when that path exists. It preserves an existing absolute path when the cwd-prefixed path do…Full details: Out of Scope Changes check
Explanation
The new HTTP 400 response for missing or malformed
sourcerequests is not connected to the coding objectives in [#281] or [#176]. Those issues require correct source-path resolution. The PR adds implementation and tests for request validation and response termination. The#451reference does not establish linked scope.Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share