Repository navigation
fix(app): let a plugin server's event stream follow its endpoint - #60087
Conversation
A plugin server restored from the plugin's last inventory starts on the placeholder endpoint 127.0.0.1:0. Its event stream read `reconnect` once at creation, so after the plugin reported the real endpoint the stream kept retrying port 0 and the server's sessions never loaded. The stream now resolves the plugin's current endpoint on every reconnect, and a connected stream moves as soon as the plugin reports a new endpoint. Closes anomalyco#60005
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
The fix works. I ran the #60005 reproduction against the real createServerSdkContext with a fake fetch. On the base, the event stream keeps retrying 127.0.0.1:0/api/event after the plugin reports its endpoint. With this change, only the retry already in flight still goes to port 0; every later request goes to the reported endpoint and stays there. The new browser test fails on the base and passes here, 5 runs out of 5. The other runtime/server tests and tsc -b pass.
The public API is unchanged: everything changed is internal to packages/app. ServerTransport.update now keeps its clients when the endpoint is unchanged.
I found nothing that blocks a merge.
Related: #57807
There was a problem hiding this comment.
My earlier review had no open points. The new commit copies the endpoint into plain values, so a password changed in place on the plugin's endpoint now rebuilds the clients. It drops nothing, since the endpoint type has only url and password. I re-ran the #60005 reproduction, the new browser test, the runtime/server unit tests and tsc -b on the new head: the stream still follows the reported endpoint and everything passes. The public API is unchanged. Nothing new to raise.
Closes #60005. A plugin's server now loads after a Desktop restart: its event stream follows the endpoint the plugin reports instead of retrying
127.0.0.1:0.Cause
runtime/plugin/servers.tsxrestores a plugin's last inventory on the placeholder endpointhttp://127.0.0.1:0, and the app creates the server's SDK before the plugin reports. The transport moved to the real endpoint, but the event stream kept the API it was created with. Its only way out,reconnect, was read once at creation and wasundefinedfor the placeholder.Change
reconnectif it has one at that moment, otherwise it takes the plugin's current endpoint.reconnectalready moved the stream is not asked again.runtime.tsx).Tests
test-browser/plugin-server-stream.test.tsdrives the realcreateServerSdkContext: the server starts on the placeholder, the plugin reports an endpoint, then another.This replaces #60006 by @Belkata, which found the cause. This PR also moves a connected stream when the endpoint changes and keeps the change inside the SDK context.
Visual
Added by the opencode bot (AI-generated).
Related: #57807