Devtools events lost when using Nitro v3 (worker_threads isolates globalThis)
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 499
- Fork
- 100
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
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:
- Set up a TanStack Start app using
nitro()(Nitro v3) instead ofnitroV2Plugin - Emit devtools events from server code (e.g. TanStack AI streaming, or any library using
@tanstack/devtools-event-client) - 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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách lần theo EventClient và ServerEventBus quanh globalThis.TANSTACK_EVENT_TARGET, sau đó tái hiện với plugin Vite nitro() và thiết lập Nitro v3 worker_threads được mô tả trong issue. So sánh ranh giới giữa worker và main thread của Vite, đồng thời xác minh rằng các sự kiện Devtools phía server đến được panel mà không cần HTTP workaround.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript, vite
- Lĩnh vực
- backend-api-design, devtools
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100