Skip to content

fix: prevent infinite RPC reconnection loop and respect app.baseURL in devtools#278

Open
timdamen wants to merge 2 commits intomainfrom
fix/devtools-reconnection-loop
Open

fix: prevent infinite RPC reconnection loop and respect app.baseURL in devtools#278
timdamen wants to merge 2 commits intomainfrom
fix/devtools-reconnection-loop

Conversation

@timdamen
Copy link
Copy Markdown
Collaborator

@timdamen timdamen commented Apr 1, 2026

Summary

Fixes #243

  • Reconnection loop: Add a hasConnected guard in client/app/composables/rpc.ts so the initial connected() RPC call only fires once, preventing repeated scan triggers when the devtools iframe reconnects behind a reverse proxy
  • baseURL support: Use joinURL(nuxt.options.app.baseURL, DEVTOOLS_UI_ROUTE) in src/devtools.ts so the custom devtools tab iframe respects app.baseURL, matching the fix applied in @nuxt/fonts (nuxt/fonts#395)

…n devtools

Closes #243

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c78ee95-d85d-4de7-a35e-9cbed58c7101

📥 Commits

Reviewing files that changed from the base of the PR and between 9223cb0 and 141c61e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • client/app/composables/rpc.ts
  • package.json
✅ Files skipped from review due to trivial changes (2)
  • client/app/composables/rpc.ts
  • package.json

📝 Walkthrough

Walkthrough

Adds a module-scoped hasConnected guard in the RPC composable so the devtools client's connected() call runs only once on initial connection (errors are still caught and logged). Updates the DevTools custom tab iframe src to respect the app's baseURL by computing it with joinURL(nuxt.options.app?.baseURL || '/', DEVTOOLS_UI_ROUTE) and imports joinURL from ufo. Also adds ufo as a runtime dependency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes both main changes: preventing RPC reconnection loop and respecting app.baseURL in devtools, directly matching the changeset content.
Description check ✅ Passed The description clearly explains the two fixes with references to the issue (#243) and related changes, directly related to the changeset modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/devtools-reconnection-loop

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/devtools.ts (1)

8-8: Consider declaring ufo as a direct dependency for clarity.

The import joinURL from ufo works because ufo is a transitive dependency of @nuxt/kit (which is already a direct dependency). However, for better maintainability, explicitly declare ufo in package.json's dependencies to avoid relying on transitive dependency stability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/devtools.ts` at line 8, The import of joinURL in src/devtools.ts comes
from a transitive dependency (ufo via `@nuxt/kit`); add "ufo" to package.json
dependencies to make it a direct dependency and avoid relying on transitive
stability. Update package.json by adding the appropriate ufo version (match the
version used by `@nuxt/kit` or bump to a compatible one), run npm/yarn install,
and then verify src/devtools.ts still imports joinURL successfully.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@client/app/composables/rpc.ts`:
- Around line 71-78: The guard variable hasConnected is being set before the
awaited handshake call nuxtA11yRpc.value!.connected(), so if connected() throws
the flag prevents retries; move the assignment of hasConnected = true so it only
runs after await nuxtA11yRpc.value!.connected() completes successfully (i.e.,
perform the await inside the try, and set hasConnected = true after the awaited
call), leaving the catch to handle errors without flipping the guard.

---

Nitpick comments:
In `@src/devtools.ts`:
- Line 8: The import of joinURL in src/devtools.ts comes from a transitive
dependency (ufo via `@nuxt/kit`); add "ufo" to package.json dependencies to make
it a direct dependency and avoid relying on transitive stability. Update
package.json by adding the appropriate ufo version (match the version used by
`@nuxt/kit` or bump to a compatible one), run npm/yarn install, and then verify
src/devtools.ts still imports joinURL successfully.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d558cd0-c7ce-43f9-b962-d1379f5cdeee

📥 Commits

Reviewing files that changed from the base of the PR and between 84670ce and 9223cb0.

📒 Files selected for processing (2)
  • client/app/composables/rpc.ts
  • src/devtools.ts

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/a11y@278

commit: 141c61e

@timdamen timdamen requested a review from danielroe April 1, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite RPC reconnection loop when running behind reverse proxy (nginx)

1 participant