TanStack / TanStack/devtools

Devtools events lost when using Nitro v3 (worker_threads isolates globalThis)

Open
#390 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
499
Forks
100
Avg merge
1d 17h
Merged PRs (30d)
4

Description

TanStack Devtools version

0.9.13

Framework/Library version

TanStack Start v1.149.3, Nitro v3.0.1-nightly

Describe the bug and the steps to reproduce it

When using TanStack Start with the nitro() Vite plugin (Nitro v3 nightly) rather than nitroV2Plugin, devtools events emitted from server code never reach the devtools panel.

The root cause is that Nitro v3's NodeEnvRunner runs server code in a worker_threads Worker during dev. EventClient dispatches events to globalThis.__TANSTACK_EVENT_TARGET__
inside the worker thread, but ServerEventBus is listening on a different globalThis.__TANSTACK_EVENT_TARGET__ in the Vite main thread. The events are emitted but never received.

This doesn't happen with nitroV2Plugin because that plugin is build-only — in dev, Start uses its own RunnableDevEnvironment which runs in-process and shares the same global scope.

Steps to reproduce:

  1. Set up a TanStack Start app using nitro() (Nitro v3) instead of nitroV2Plugin
  2. Emit devtools events from server code (e.g. TanStack AI streaming, or any library using @tanstack/devtools-event-client)
  3. Open the devtools panel — server-side events are missing

Workaround:
We confirmed the issue by manually bridging events from the Nitro worker to the Vite process over HTTP — intercepting tanstack-dispatch-event on the worker's
globalThis.__TANSTACK_EVENT_TARGET__ and POSTing the payload to a Vite dev server middleware that re-dispatches it on the main thread's event target. This works but is hacky.

Apologies for the double-post — originally mentioned this in Discord, just filing here too since it might be easier to track.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

n/a

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing EventClient and ServerEventBus around globalThis.TANSTACK_EVENT_TARGET, then reproduce with the nitro() Vite plugin and Nitro v3 worker_threads setup described in the issue. Compare the worker and Vite main-thread boundaries and verify that server-side devtools events reach the panel without the HTTP workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
backend-api-design, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.