fix(devframe,hub): republish remote-dock WS endpoint once it resolves - #217
Merged
Conversation
Port the second half of vitejs/devtools#520: a remote iframe dock registered before the standalone WebSocket transport finishes binding (the common `initHub` sequence — devframes, and their docks, install before an async side-car/shared-server port resolves) was projected without a connection descriptor, since `wsEndpoint` wasn't set yet. Nothing re-registered that dock once the port resolved, so it kept a stale/empty connection URL for the life of the process. `DevframeInternalContext` now exposes `setWsEndpoint`/`onWsEndpointChange` so subscribers learn when the endpoint changes instead of reading a plain field once at registration time. The hub context subscribes and re-projects every dock into `devframe:docks` shared state whenever the endpoint resolves (or is torn down). #171 already covers the atomic-bind half of #520. Co-authored-by: webfansplz <webfansplz@gmail.com> Refs: vitejs/devtools#520, vitejs/devtools#517
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Closes #206, which asked to verify the second half of vitejs/devtools#520 ("allocate standalone WebSocket ports atomically") by @webfansplz, fixing vitejs/devtools#517: once an async WS bind resolves its port, already-registered remote iframe docks need their connection URL republished.
The atomic-bind half already shipped in #171 (merged, in
0.9.0-beta.2). This PR closes the remaining gap: the WS-endpoint republish.The gap
initHubinstalls every mounted devframe — and registers their docks — before resolving the WS transport (an async side-car port probe, or theunboundtier waiting on the host's ownattach()). A remote iframe dock registered in that window got projected intodevframe:docksshared state without a connection descriptor, becauseDevframeInternalContext.wsEndpointwasn't set yet. Nothing re-ran that projection once the port resolved, so the dock kept a bare/unusable URL for the life of the process — the same class of bug as the oldws.ts'sdock:entry:updatedre-emit that #520 fixed upstream, just in this repo's hub-internals path instead.Fix
DevframeInternalContextgainssetWsEndpoint()/onWsEndpointChange()— every WS-binding tier (side-car, shared-server, and theunboundtier'sattach()) now sets the endpoint through this instead of a plain field assignment, so subscribers learn when it changes.devframe:docksshared state whenever the endpoint resolves (or is torn down), alongside the existingdock:entry:updatedtrigger.Testing
packages/hub/src/node/__tests__/context.test.ts) that registers a remote dock before the WS endpoint is known, asserts it's un-enriched, then resolves the endpoint and asserts the shared-state entry picks up the connection URL. Verified it fails without the fix and passes with it.pnpm build && pnpm vitest run && pnpm typecheckall pass.Credit to @webfansplz for the original diagnosis and fix upstream (vitejs/devtools#520, vitejs/devtools#517).
This PR was created with the help of an AI agent.