Skip to content

Resolve the devtools import afresh after re-optimization; pre-bundle the diagnostics bridge - #351

Merged
ryansolid merged 1 commit into
solidjs:nextfrom
brenelz:fix/devtools-optimizer-hash
Sep 8, 2026
Merged

Resolve the devtools import afresh after re-optimization; pre-bundle the diagnostics bridge#351
ryansolid merged 1 commit into
solidjs:nextfrom
brenelz:fix/devtools-optimizer-hash

Conversation

@brenelz

@brenelz brenelz commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

A new Solid 2 project created with the development toolbar (create-solid --devtools, which adds @solidjs/start-devtools) breaks under vite dev on first load:

GET /node_modules/.vite/deps/error-viewer-….js?v=1229790f net::ERR_ABORTED 504 (Outdated Optimize Dep)
[warn] You appear to have multiple instances of Solid.
[warn] Hydration key miss for "1702" …
[error] [REACTIVITY_HALTED] An uncaught error halted the reactive system.

Two things combine:

  1. The generated entries froze the toolbar's optimizer URL. resolveDevtools memoized the id it detected @solidjs/start-devtools with and resolveId handed that id back for the generated entries' import. In the client environment that id is the optimizer's pre-bundled URL, stamped with the browserHash of the pass that produced it. Any dependency discovered after the initial scan re-optimizes — the toolbar's chunks are re-emitted under new names and the hash moves on — and the frozen id kept the entry on the previous pass: the toolbar's lazy chunks answer 504 Outdated Optimize Dep, and the stale bundle brings a second solid-js instance into the page. In the served entry every import carried the new hash except the toolbar's.
  2. The diagnostics bridge triggered exactly that re-optimize on the first load. virtual:solid-diagnostics/client imports @solidjs/diagnostics/browser and /protocol, but the scanner never crawls that virtual module and nothing pre-bundled them, so the first page load discovered them, re-optimized and reloaded. The solid-v2 templates all enable diagnostics, so every fresh project hit this.

Fix

  • src/ssr/index.ts: resolveId resolves @solidjs/start-devtools afresh on every request, from the app importer detection probed. Detection is still memoized per consumer, but only its verdict.
  • src/diagnostics/index.ts: a config hook pre-bundles the bridge's two imports whenever the surface is enabled (explicit true, or auto-detected from the app manifest — same gate as before).

Test

examples/start-ssr/test/run.mjs (dev mode) gains two assertions: a probe module imports @solidjs/web/frames/client, which forces a reload-class re-optimization (it shares chunks with the already-bundled deps, so Vite has to rewrite them; a dependency that only adds a standalone bundle keeps the old hashes and reloads nothing), and the generated entry's toolbar import must move to the same hash as its @solidjs/web import.

  • patched: 67/67
  • unpatched source, same harness: 66/67 — only the new toolbar assertion fails (start-devtools ?v=5784662f -> ?v=5784662f, @solidjs/web ?v=ba4c7b03)

Also verified against a create-solid --solid basic --devtools --ssr project with this build installed: first load has no re-optimize, and after a forced mid-session re-optimization the reloaded page fetches the toolbar and its error-viewer chunk at the new hash with a clean console.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a3cc782

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/vite-plugin@351

commit: a3cc782

…the diagnostics bridge

New Solid 2 projects created with the development toolbar broke under
`vite dev` on first load: the toolbar's lazy chunks answered
`504 Outdated Optimize Dep`, a second solid-js instance entered the page,
and hydration failed (REACTIVITY_HALTED).

The generated entries' `@solidjs/start-devtools` import reused the id
captured when the toolbar was detected. In the client environment that id
is the optimizer's pre-bundled URL, stamped with the browserHash of the
pass that produced it. Any dependency discovered after the initial scan
re-optimizes — the toolbar's chunks are re-emitted under new names and the
hash moves on — and the frozen id kept the entry on the previous pass.
resolveId now resolves the package afresh on every request, from the app
importer detection probed; detection itself stays memoized, verdict only.

The trigger every fresh template project hit is removed too: the agent
diagnostics bridge reaches the page through a virtual module the scanner
never crawls, so its two imports (`@solidjs/diagnostics/browser` and
`/protocol`) were only discovered on the first page load, forcing exactly
that re-optimize + reload. The diagnostics plugin pre-bundles them whenever
the surface is enabled.

The start-ssr dev harness gains a regression check: a probe import forces
a reload-class re-optimization and the generated entry's toolbar import
must move to the same hash as its `@solidjs/web` import. It fails on the
previous code (66/67) and passes with this change (67/67).
@ryansolid
ryansolid force-pushed the fix/devtools-optimizer-hash branch from 6d8d6be to a3cc782 Compare September 8, 2026 17:35
@ryansolid

Copy link
Copy Markdown
Member

Reviewed for the rc.7 release train. The fresh resolveId keeps detection's importer/fallback semantics and only drops the frozen id; the diagnostics config hook is gated by the plugin's apply (serve, non-preview, non-test) plus the same explicit-true / app-manifest auto-detect rule as configResolved. Verified the resolved config: diagnostics: true@solidjs/diagnostics/browser + /protocol in the client environment's optimizeDeps.include only (SSR env untouched, noDiscovery: true); false / undetected auto → nothing; vite build → nothing.

Rebased onto next (now on top of #350 rc.7 ride + #343) and gated locally on the rebased commit: dev mode 67/67 with both new devtools assertions, full start-ssr 500/500 + http-bridge 10/10 + components-warning 9/9, ssr 12/12 + 8/8, css-matrix 87/87 + 19/19, start-client 45/45, start-env 47/47. Merging once CI is green.

@ryansolid
ryansolid merged commit 67297c9 into solidjs:next Sep 8, 2026
6 checks passed
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.

2 participants