You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A plugin's text/event-stream response under /api permanently blocks the desktop update drain
#13773
A plugin's text/event-stream response under /api permanently blocks the desktop update drain
TL;DR
installDesktopUpdateTaskControl drains in-flight /api requests with await Promise.all(pendingRequests) before an in-app update. Its connection/request listener awaits next(), which — as the client-connection docs state — resolves only through response completion. A plugin route registered with ctx.connection.fetch.register that answers text/event-stream never completes its response, so its entry stays in the set for the lifetime of the Host. Every subsequent update attempt burns the full 10 s budget and fails with desktop update: task inspection timed out, with no way out short of quitting the app.
This is deterministic and plugin-triggered, and it is not a "slow request" problem. Two A/B runs on the same machine are in the Evidence section; after the plugin stopped holding a response open, the same update installed on the first click.
Two corrections to earlier reports, both verified here:
WebSockets do not participate. Upgrade requests go through webServer.registerUpgrade; only the webServer.register/api prefix route runs the connection/request waterfall.
Routes outside /api do not participate either — they reach the server through ctx.webServer.register and never enter the drained set. Only HTTP responses under /api are tracked, so the trigger is specifically a never-ending response body, not a persistent socket.
Update payload already downloaded and verified; install fails before any installation work starts.
Symptom
Clicking "Install update" shows the "tasks are running, stop them?" confirmation, then fails after a full 10 s:
Update failed, please try again later.
desktop update: task inspection timed out
The confirmation appearing tells us updateTasks('inspect') succeeded; the failure is in updateTasks('lock'), i.e. the drain, not the task inspection.
Evidence
A/B on one machine
Third-party bundles
Result
All disabled (official bundles only)
Update installs normally
All disabled except one plugin
Fails every attempt, including the first attempt after a fresh restart
That one plugin's stream removed (see below)
Installs on the first click, no other change
The failure reproduces immediately after a cold start, so it is not residue from an earlier abandoned request: the plugin opens its stream as soon as its client-side extension loads.
Why "slow request" is the wrong model
An earlier round of plugin-side work rewrote every long-running handler to answer 202 + { id } and let the work continue as a background job, with the client polling for the result. That correctly bounds handler time — and it did not fix this failure, because a 202 response completes while an event stream does not. Both cases take the same await next() path; only completion matters.
constpendingRequests=newSet();ctx.on('connection/request',async(_request,response,next)=>{if(locked){response.writeHead(503);response.end();return;}constfinished=Promise.withResolvers();pendingRequests.add(finished.promise);try{awaitnext();// resolves when the response completes}finally{pendingRequests.delete(finished.promise);finished.resolve();}});returnasync(action)=>{// ...if(action==='lock'){locked=true;constgeneration=++lockGeneration;awaitPromise.all(pendingRequests);// waits for the event stream's lifetime// ...}returnhasDesktopActiveTasks(agents.list(),jobs);};
The contract is documented in client-connection:
Authenticated shared HTTP requests pass through the connection/request waterfall before body transfer. A listener may refuse new requests or await next() through response completion.
And only the /api prefix route installs that waterfall:
bridge() resolves when the response ends. For text/event-stream that is when the client disconnects, so the drain is unbounded by construction. The 10 000 ms budget exists only on the shell side (updateTasks control), and its expiry leaves the set untouched — there is no exemption and no forced-continue path.
Client side, open it with new EventSource('/api/example-events'). From then on, until the plugin is disabled or the app quits, in-app updates fail at the drain. This is the natural shape for a live panel, and the platform explicitly supports streaming request bodies, so nothing about it looks wrong to a plugin author.
Impact
The failure is not degraded — it is total. A user who installs one such plugin can no longer update the app through the UI, gets no diagnostic beyond a generic message, and has no override. Because the trigger is created on client load, restarting does not help. Diagnosing it took packet capture and byte-level inspection of app.asar, which is not a reasonable bar for users.
Suggested fixes
Platform side, in order of value:
Exempt long-lived responses from the drain. Give connection.fetch.register an explicit declaration (e.g. longLived: true, or infer from content-type: text/event-stream) and skip those responses when draining. This makes the platform's own streaming support usable.
Bound the drain and keep it debuggable. Race Promise.all(pendingRequests) against the remaining budget, and on expiry report which requests are pending (method, path, age) in both the error and a diagnostics log. A single line naming the route would have replaced the entire investigation above.
Provide a forced exit. When the drain cannot finish but the user has already agreed to stop active tasks, the shell can stop the Host with SIGTERM/SIGKILL; the drain should not be the only gate in front of that path.
Documentation side: state that plugins must not hold an /api response open, and suggest short polling (cursor or after sequence) for event feeds until (1) ships. Also worth noting in the docs that webServer.register routes bypass the drain — it is not a substitute, since only /api carries the authenticated peer, but it explains why some plugins never hit this.
This report adds a third-party plugin as the confirmed trigger source, the A/B result, the WebSocket correction, and the fact that a plugin-side protocol change restores updates without touching DSH.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
A plugin's
text/event-streamresponse under/apipermanently blocks the desktop update drainTL;DR
installDesktopUpdateTaskControldrains in-flight/apirequests withawait Promise.all(pendingRequests)before an in-app update. Itsconnection/requestlistener awaitsnext(), which — as theclient-connectiondocs state — resolves only through response completion. A plugin route registered withctx.connection.fetch.registerthat answerstext/event-streamnever completes its response, so its entry stays in the set for the lifetime of the Host. Every subsequent update attempt burns the full 10 s budget and fails withdesktop update: task inspection timed out, with no way out short of quitting the app.This is deterministic and plugin-triggered, and it is not a "slow request" problem. Two A/B runs on the same machine are in the Evidence section; after the plugin stopped holding a response open, the same update installed on the first click.
Two corrections to earlier reports, both verified here:
webServer.registerUpgrade; only thewebServer.register/apiprefix route runs theconnection/requestwaterfall./apido not participate either — they reach the server throughctx.webServer.registerand never enter the drained set. Only HTTP responses under/apiare tracked, so the trigger is specifically a never-ending response body, not a persistent socket.Environment
0.2.2-rc.3→0.2.2-rc.5, nightly channel.desktopprofile.Symptom
Clicking "Install update" shows the "tasks are running, stop them?" confirmation, then fails after a full 10 s:
The confirmation appearing tells us
updateTasks('inspect')succeeded; the failure is inupdateTasks('lock'), i.e. the drain, not the task inspection.Evidence
A/B on one machine
The failure reproduces immediately after a cold start, so it is not residue from an earlier abandoned request: the plugin opens its stream as soon as its client-side extension loads.
Why "slow request" is the wrong model
An earlier round of plugin-side work rewrote every long-running handler to answer
202 + { id }and let the work continue as a background job, with the client polling for the result. That correctly bounds handler time — and it did not fix this failure, because a202response completes while an event stream does not. Both cases take the sameawait next()path; only completion matters.Mechanism
dsh-desktop-host/lib/index.js,installDesktopUpdateTaskControl:The contract is documented in
client-connection:And only the
/apiprefix route installs that waterfall:bridge()resolves when the response ends. Fortext/event-streamthat is when the client disconnects, so the drain is unbounded by construction. The 10 000 ms budget exists only on the shell side (updateTaskscontrol), and its expiry leaves the set untouched — there is no exemption and no forced-continue path.Minimal reproduction
Any plugin:
Client side, open it with
new EventSource('/api/example-events'). From then on, until the plugin is disabled or the app quits, in-app updates fail at the drain. This is the natural shape for a live panel, and the platform explicitly supports streaming request bodies, so nothing about it looks wrong to a plugin author.Impact
The failure is not degraded — it is total. A user who installs one such plugin can no longer update the app through the UI, gets no diagnostic beyond a generic message, and has no override. Because the trigger is created on client load, restarting does not help. Diagnosing it took packet capture and byte-level inspection of
app.asar, which is not a reasonable bar for users.Suggested fixes
Platform side, in order of value:
connection.fetch.registeran explicit declaration (e.g.longLived: true, or infer fromcontent-type: text/event-stream) and skip those responses when draining. This makes the platform's own streaming support usable.Promise.all(pendingRequests)against the remaining budget, and on expiry report which requests are pending (method, path, age) in both the error and a diagnostics log. A single line naming the route would have replaced the entire investigation above.Documentation side: state that plugins must not hold an
/apiresponse open, and suggest short polling (cursor oraftersequence) for event feeds until (1) ships. Also worth noting in the docs thatwebServer.registerroutes bypass the drain — it is not a substitute, since only/apicarries the authenticated peer, but it explains why some plugins never hit this.Related discussions
installDesktopUpdateTaskControlunchanged across releases, budget still1e4.This report adds a third-party plugin as the confirmed trigger source, the A/B result, the WebSocket correction, and the fact that a plugin-side protocol change restores updates without touching DSH.
All reactions