Skip to content

Bug: Vite optimizeDeps race condition causes React not found in dev mode #16766

@abcfy2

Description

@abcfy2

Astro Info

Astro                    v6.3.3
Node                     v24.15.0
System                   Linux (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

All browsers (tested in Chrome).

Describe the Bug

In dev mode (pnpm dev), when using @astrojs/node adapter + @astrojs/react + Astro Actions + React island with @inlang/paraglide-js and @tailwindcss/vite as Vite plugins, two errors occur:

1. React hydration failure:

[astro-island] Error hydrating /src/components/Counter.tsx
SyntaxError: The requested module "react-dom/client.js"
does not provide an export named "createRoot"

2. Dev toolbar 504:

GET http://localhost:4321/@id/astro/runtime/client/dev-toolbar/entrypoint.js
net::ERR_ABORTED 504 (Outdated Optimize Dep)

After git clean -fdx && pnpm i, Vite's node_modules/.vite/deps/_metadata.json contains only 1 entry:

Total optimized: 1
  astro/actions/runtime/entrypoints/route.js

Expected React entries (react, react-dom, react-dom/client, react/jsx-runtime, @astrojs/react/client.js) are all missing.

pnpm build is NOT affected — production build works correctly.

What's the expected result?

React islands should hydrate and the dev toolbar should load in dev mode without errors. _metadata.json should contain all React dependencies.

Link to Minimal Reproducible Example

https://github.com/abcfy2/astro-react-hydration-bug-repro

git clone https://github.com/abcfy2/astro-react-hydration-bug-repro
cd astro-react-hydration-bug-repro
pnpm i
pnpm dev
# Open http://localhost:4321/ → console shows createRoot error

Related: #16387

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)pkg: reactRelated to React (scope)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions