kit icon indicating copy to clipboard operation
kit copied to clipboard

Use the new Vite Runtime API to support server-side HMR correctly

Open garrappachc opened this issue 1 year ago • 2 comments

Describe the problem

Currently used vite.ssrLoadModule() doesn't support the HMR API fully. Vite doesn't call hot.dispose/hot.accept functions for invalidated modules, thus making server-side long-living tasks (i.e. setInterval() or event listener callbacks) stack on top of each other each time a reload happens.

Describe the proposed solution

Call runtime.executeEntrypoint() instead of vite.ssrLoadModule().

Alternatives considered

No response

Importance

i cannot use SvelteKit without it

Additional Information

No response

garrappachc avatar Mar 05 '24 08:03 garrappachc

Second this. Would be a very helpful improvement.

nzav avatar May 18 '24 00:05 nzav

I experience the same problem with WebSocket httpServer which is started in Svelte's hooks.server.ts - it remains running and throwing EADDRINUSE (port/address in use).

fdebef avatar Oct 10 '24 06:10 fdebef