TanStack / TanStack/devtools

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

オープン
#390 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
499
フォーク
100
平均マージ
1日 17時間
マージ済み PR(30日)
4

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず globalThis.TANSTACK_EVENT_TARGET 周辺の EventClient と ServerEventBus を追跡し、次に issue に記載されている nitro() Vite プラグインと Nitro v3 worker_threads セットアップで再現します。worker と Vite のメインスレッドの境界を比較し、サーバー側の Devtools イベントが HTTP workaround なしでパネルに到達することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript, vite
領域
backend-api-design, devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。