svelte-adapter-bun icon indicating copy to clipboard operation
svelte-adapter-bun copied to clipboard

SvelteKit demo app not working

Open peterlerche opened this issue 1 year ago • 3 comments

Desperate to find a solution to #38 I made a clean installation of Svelte demo app using the guide on https://bun.sh/guides/ecosystem/sveltekit.

When browsing the demo app, I get a lot of the below faults.

709 | }); 710 | }; 711 | var get_origin = function(headers) { 712 | const protocol = protocol_header && headers.get(protocol_header) || "https"; 713 | 714 | const host = headers.get(host_header); ^ TypeError: Invalid header name: '' at get_origin (/my-app/build/index.js:714:15) at ssr (/my-app/build/index.js:682:23)

Why do we see these faults, is Bun changing their internals or is svelte-adapter-bun out of sync with the newer version of bun?

All help, ideas, and guidance will be appreciated.

peterlerche avatar Nov 10 '23 10:11 peterlerche

I have the same problem in a "real" application, not just the demo.

Dan1ve avatar Nov 11 '23 12:11 Dan1ve

Until this has been merged, it seems a fix is to set the following env variables:

PROTOCOL_HEADER=x-forwarded-proto
HOST_HEADER=x-forwarded-host

Dan1ve avatar Nov 11 '23 17:11 Dan1ve

I've forked this repo and published my own NPM package. The fix for this issue is already merged into my fork and I plan to keep it updated. Anyone else having this issue is free to use it if you'd like:

bun add @catdadcode/svelte-adapter-bun -D

https://github.com/catdadcode/svelte-adapter-bun

I've also added signal event handling to the fork. Previously if you ran your Svelte app in a Docker container then killing the container would take 10+ seconds before Docker would force kill it. The resulting build/ app from this adapter now has proper process signal handling and will gracefully shutdown immediately upon receiving any of SIGTERM, SIGINT, SIGQUIT, SIGSTOP, or SIGKILL.

chevcast avatar Nov 24 '23 01:11 chevcast