Repository navigation
fix: dispose Cloudflare platform proxy when Vite servers close - #17216
svelte-triage-bot[bot] wants to merge 1 commit into
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/d5d1cdb530ca0c5f28184eaf096c1f721fd54d89Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: d5d1cdb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Nic-Polumeyv
left a comment
There was a problem hiding this comment.
The server.close wrapper is lost on restart: restartServer closes via _closeServer('restart') and Object.assign(server, newServer) replaces close, so after a vite.config edit the final close never disposes the proxy (reproduced locally).
Use Vite 8.3's closeServer / closePreviewServer instead (vitejs/vite#23110). Below 8.3 they never fire, which is acceptable. Skipping reason === 'restart' is required because the new server's configureServer already ran against the existing global and inherits the proxy.
const dispose = async () => {
const proxy = globalThis.__sveltekit_cloudflare_platform;
if (!proxy) return;
Reflect.deleteProperty(globalThis, '__sveltekit_cloudflare_platform');
await proxy.dispose();
};
// ...
closeServer: ({ reason }) => (reason === 'close' ? dispose() : undefined),
closePreviewServer: dispose,This drops the memoised disposal and the ownership guard, so one real-server close test is enough.
|
@svelte-triage-bot Hello? are we working on my review? |
|
Closed in favour of #17238 |
platformtocloudflare:workers#16754 eagerly created a Wrangler platform proxy but never released its Miniflare handles; the global is required socloudflare:workers,Request.cf, andcachesshare one proxy.close()to close Vite concurrently with one memoized disposal and only clear the still-owned global; rejectcloseBundlebecause Vite 8.2 preview does not invoke it and reject Vite 8.3 close hooks because the adapter supports Vite 8.0+.Fixes #17215