{{ message }}
Repository navigation
fix(devtools-bundler-core): open source files outside cwd and end bad open-source requests - #541
Open
AlemTuzlak wants to merge 1 commit into
Open
AlemTuzlak wants to merge 1 commit into
AlemTuzlak wants to merge 1 commit into
Conversation
… open-source requests addSourceToJsx strips cwd from the module path. A file outside cwd (a monorepo package, or Vite run from another directory) keeps its absolute path, and the open-source handler then prefixed cwd again. The editor got paths like /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 one does. A missing or malformed `source` returned without ending the response, so the request stayed pending until the browser timed out. It now answers 400. Fixes #281 Fixes #176 Refs #451
|
View your CI Pipeline Execution ↗ for commit 32e150a
☁️ Nx Cloud last updated this comment at |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

"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
400for a badsource, 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.sourcereturned withoutres.end(), so the request stayed pending until the browser timed out (the server part of Click-to-source sends empty source= and hangs because setDisabledAfterClick(true) runs before reading highlightState.dataSource #451). It now answers400.✅ Checklist
pnpm test:pr, or these tests do not apply to this pull request.🚀 Release Impact
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.pnpm test:pr.Manual test
apps/weband render a component frompackages/pkg. Or use the StackBlitz repro in Click-to-code does not work when command run from different directory #281.packages/pkg/src/...at the right line./__tsd/open-source?source=in the browser. Before: pending forever. After:400.How this PR makes testing easy
Unit tests in
utils.test.tscover a file outside cwd (the repo rootpackage.json) and the400answers.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