Node-adapted app crashes on request if referenced ADDRESS_HEADER is missing #10284
Labels
bug
Something isn't working
p1-important
SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
pkg:adapter-node
Describe the bug
Making a request to a non-prerendered page of a Node-adapter application with
ADDRESS_HEADER
set to a header that's not present in the request crashes the application. This happens even if the user code does not usegetClientAddress
anywhere.Reproduction
npm run build
ADDRESS_HEADER=blah node build
curl localhost:3000/sverdle
This crashes the server for me. Interestingly,
curl localhost:3000
does not crash the server, presumably because that page is prerendered.Logs
System Info
Severity
serious, but I can work around it
Additional Information
I think we should just move the check for the header referenced in
ADDRESS_HEADER
into thegetClientAddress
callback we pass back from the adapted output. We definitely don't want to crash the app. Another possibility would be to make that be an instant 500 without calling any of the underlying SvelteKit code (and without waiting forgetClientAddress()
to be called), but that doesn't seem quite necessary (maybe the user wants to handle that case!) and I'm not sure what a nice way to do that would be without duplicating SvelteKIt'serror.html
templating logic.I'm working around this for now by simply using the appropriate headers directly - with my own fallbacks if they don't exist - rather than trying to use
getClientAddress()
.The text was updated successfully, but these errors were encountered: