refactor(dev): drop the Vite-under-Bun proxy workarounds Bun 1.4.1 made obsolete - #503
Draft
DavidBabinec wants to merge 1 commit into
Draft
refactor(dev): drop the Vite-under-Bun proxy workarounds Bun 1.4.1 made obsolete#503DavidBabinec wants to merge 1 commit into
DavidBabinec wants to merge 1 commit into
Conversation
…de obsolete Three pieces of this repo existed only because the Vite dev server runs inside Bun and Bun's node:http client had gaps: it never emitted 'upgrade', its socket lacked destroySoon(), and its proxy could stop draining large bodies under backpressure. Bun 1.4.1 fixed the socket lifecycle (ws handleUpgrade after await, paused sockets never emitting end, WebSocket backpressure stalls), and on 1.4.2 the workarounds are dead weight: - vite.config.ts forwards WebSocket upgrades on /admin/api (ws: true). The VITE_CMS_DEV_PORT define and the large-body proxy plugin are gone. - The collab socket is same-origin in dev exactly as in production: window.location.host + SITE_SOCKET_PATH. socketUrl.ts and its test are deleted along with the import.meta.env.DEV special case. - scripts/lib/largeBodyDevProxy.ts and its test are deleted. - devWorkflow.test.ts now gates the other way: ws forwarding must stay on and no CMS port may be dialled directly. - docs/features/site-shell.md and docs/e2e/README.md describe the same-origin dev socket and no longer document the plugin. A throwaway workflow, .github/workflows/vite-dev-smoke.yml, boots the CMS and the Vite dev server on a Linux runner and asserts that Vite comes up and that a WebSocket upgrade through the proxy returns a status line instead of hanging; that is the failure the E2E workflow first died on. The file is removed before merge. Verification (Bun 1.4.2): bun run build tsc + vite clean bun run lint clean bun test 6827 pass, 0 fail bun run dev, browser on the Vite port collab socket opens through the proxy in 6 ms, then Vite survives its close media upload through the proxy 1.48 MiB PNG, HTTP 201 in 0.16 s, all bytes received vite-dev-smoke on ubuntu-latest see the PR (runs on push)
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.
What changed
Stacked on #502 (Bun 1.4.2). Deletes the three workarounds this repo carried for running the Vite dev server inside Bun:
vite.config.tsforwards WebSocket upgrades on/admin/api(ws: true). TheVITE_CMS_DEV_PORTdefine and the large-body proxy plugin are gone.window.location.host+SITE_SOCKET_PATH.socketUrl.ts, its test, and theimport.meta.env.DEVspecial case are deleted.scripts/lib/largeBodyDevProxy.tsand its test are deleted.devWorkflow.test.tsgates the other way now:wsforwarding must stay on, and no CMS port may be dialled directly.docs/features/site-shell.mdanddocs/e2e/README.mdupdated.Net: 386 lines removed, 94 added, no runtime behaviour change in production (which was already same-origin).
Why
Every one of those workarounds sat on the same seam: Bun's
node:httpclient never emitted'upgrade', its socket lackeddestroySoon(), and its proxy could stop draining large bodies under backpressure. Bun 1.4.1 fixed the socket lifecycle (wshandleUpgradeafter anawait, paused sockets never emittingend, WebSocket backpressure stalls). On 1.4.2 the workarounds are dead weight, and the dev server finally behaves like production: one origin, one proxy, no port special cases.Proof
bun run build/bun run lint/bun testunder 1.4.2new WebSockettows://localhost:5291/admin/api/cms/site-socketopens in 6 ms; the editor reports Draft syncedvite-dev-smokeonubuntu-latest(Vite comes up; upgrade returns a status line)HTTP/1.1 401 Unauthorized(the CMS refusing an anonymous socket) instead of hanging. The first E2E CI run had waited 120 s for this under 1.3.11.The smoke workflow (
.github/workflows/vite-dev-smoke.yml) is a throwaway for this branch and is removed before merge.