Repository navigation
Conversation
`deno desktop` moved to an in-process memory channel + `app://` scheme handler in #35272. That broke every desktop app whose frontend connects back with `new WebSocket("ws://" + window.location.host)` — the standard pattern for real-time frontend<->backend comms: - `window.location.host` under `app://desktop/` is `desktop`, so the URL becomes `ws://desktop` and the browser fails DNS with `ERR_NAME_NOT_RESOLVED`. - The `app://` scheme handler only intercepts HTTP; it does not see `ws://` at all. - Even if it did, laufey's `SchemeExchange` is one-shot request/response (`read_body` -> `begin` -> `write` -> `finish`) with no upgrade or duplex — the WebSocket handshake could never complete over it. The same one-shot surface also blocks streamed response bodies (see #35590). Fix: restore the previous TCP-loopback serve path. `deno desktop` allocates a loopback port, `Deno.serve` binds a real TCP listener, and the webview navigates to `http://127.0.0.1:PORT` once a real HTTP response comes back. Native WebSocket (and streamed bodies) work again without any user-facing change. This is effectively a revert of #35272 with the window-reveal fix from #35620 preserved (hidden bootstrap window, `on_page_load` reveal, and the idempotent `show()` fallback are kept on top of the restored TCP navigate loop). A follow-up that keeps the memory transport perf win while supporting WebSockets would need a laufey API extension (duplex/upgradeable scheme exchange, or a scheme-level hook that hands Deno a raw bidirectional stream); that work belongs upstream in laufey. Refs #35576 Refs #35590 Closes denoland/divybot#745 Co-Authored-By: Divy Srivastava <me@littledivy.com>
|
@divybot I will land my revert for the release. I want you to investigate the root cause and fix it with in-memory transport for a reland |
|
Ack @littledivy — closing this in favor of #35670 for the release. Will open a separate reland-with-in-memory-transport PR against the root cause once #35670 lands. Preliminary root-cause note so the follow-up work has a place to start: What's broken: Reland shape (to be prototyped):
Draft PR to follow — this comment is for the record, not the fix itself. |
|
Superseded by #35670 for the release; separate reland PR to follow per @littledivy's ask above. |
|
Opened the reland as #35675 — keeps the memory transport for HTTP and adds a WebSocket-only TCP loopback proxy that reject-401s anything but a handshake, so plain HTTP still has to come through |
Summary
`deno desktop` moved to an in-process memory channel + `app://` scheme handler in #35272. That broke every desktop app whose frontend connects back with `new WebSocket("ws://" + window.location.host)` — the standard, near-universal pattern for real-time frontend↔backend comms — reported in #35576.
Under the new architecture the webview is at `app://desktop/`, so:
The same one-shot surface also blocks streamed response bodies (see #35590).
Fix
Restore the previous TCP-loopback serve path. `deno desktop` allocates a loopback port, `Deno.serve` binds a real TCP listener, and the webview navigates to `http://127.0.0.1:PORT\` once a real HTTP response comes back. Native WebSocket and streamed bodies work again with no user-facing change.
This is effectively a revert of #35272 with the window-reveal fix from #35620 preserved (hidden bootstrap window, `on_page_load` reveal, and the idempotent `show()` fallback are kept on top of the restored TCP navigate loop).
Follow-up
Recovering the memory-transport perf win while supporting WebSockets requires a laufey API extension — either a duplex/upgradeable `SchemeExchange` or a scheme-level hook that hands Deno a raw bidirectional stream. That work belongs upstream in `littledivy/laufey`; once shipped, the in-memory serve path can return behind that new API.
Alternate approach
@littledivy opened #35670 as a straight `git revert` of #35272 with the same effect. This PR is the same tree change with a `fix(desktop):` framing and a description that spells out the two failure modes (`app://` not intercepting `ws://`, and `SchemeExchange` being non-duplex). Reviewers can pick whichever framing lands better; closing one when the other merges is fine.
Verification
Refs #35576
Refs #35590
Closes denoland/divybot#745