mirror of
https://github.com/TanStack/devtools.git
synced 2026-11-16 10:49:48 +00:00
* docs: add design spec for network transport fallback in isolated server runtimes Addresses the issue where devtools events are lost when server code runs in isolated environments (Nitro v3 worker threads, Cloudflare Workers, etc.) that don't share globalThis with the Vite main thread. * docs: address spec review findings for network transport fallback Fix problem description precision, URL matching and handleNewConnection signature issues, POST handler routing, placeholder convention, triplicate interface sync, queue preservation, and multi-worker echo safety. * docs: clarify dual handler paths in network transport spec Disambiguate that both standalone and external server POST/upgrade handlers need updates, and that only WebSocket URL matching needs prefix change (not SSE/POST URLs). * docs: add implementation plan for network transport fallback 7-task plan covering: interface updates, ServerEventBus bridge support, POST handler routing, RingBuffer utility, EventClient network transport detection, WebSocket connection/emit/receive, and integration tests. * feat: add eventId and source fields to TanStackDevtoolsEvent interface * feat: add server bridge WebSocket connection support to ServerEventBus - Accept WebSocket connections with ?bridge=server query parameter - Track bridge clients separately for proper routing - Bridge messages route through emit() (broadcast to WS clients + EventTarget) - Regular browser messages route through emitToServer() (EventTarget only) - Clean up bridge client tracking on disconnect and stop() * feat: add source-based routing to POST handlers for server bridge support * feat: add RingBuffer utility for event ID deduplication * feat: add network transport detection and compile-time placeholders to EventClient * feat: add WebSocket network transport fallback to EventClient When EventClient detects it is in an isolated server environment (no shared globalThis.__TANSTACK_EVENT_TARGET__, no window), it automatically connects to ServerEventBus via WebSocket. Bidirectional: events emitted in the worker reach the devtools panel, and events from the devtools panel reach listeners in the worker. Includes echo prevention via 200-entry ring buffer, exponential backoff reconnection, HTTP POST fallback, and event queuing. * fix: improve WebSocket error handling and destroy cleanup in EventClient - Add scheduleReconnect() call in error handler for non-browser runtimes where 'close' may not follow 'error' - Reset wsGaveUp, wsReconnectAttempts, wsReconnectDelay in ___destroyNetworkTransport for safe reuse * test: add end-to-end integration tests for network transport fallback * docs: mark network transport fallback spec as implemented * ci: apply automated fixes * feat: add Nitro v3 and Cloudflare Workers test examples Two minimal examples for manually testing the network transport fallback: - examples/react/start-nitro — TanStack Start + Nitro v3 (worker threads) - examples/react/start-cloudflare — TanStack Start + Cloudflare Workers Both emit devtools events from server functions and display them in a custom "Server Events" devtools panel. If events appear in the panel, the network transport fallback is working correctly. * Refactor code structure for improved readability and maintainability * docs: design spec for native Vite HotChannel runtime bridge * docs: implementation plan for native Vite HotChannel runtime bridge * feat(devtools-vite): generate worker-side runtime bridge code * feat(devtools-vite): inject runtime bridge into event-client for server envs * feat(devtools-vite): wire dev-server hot channels to ServerEventBus * feat(devtools-vite): hook runtime bridge into plugin and dev server * chore: add devtools-vite changeset, remove planning docs from PR * fix(devtools-vite): tear down runtime-bridge hot handlers to prevent duplicate events * ci: apply automated fixes * chore: align start-nitro/start-cloudflare examples to vite 8 (fix sherif) * test(devtools-vite): use explicit function types in runtime-bridge mocks (eslint) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
30 lines
800 B
30 lines
800 B