Clarify response vs request headers for the setup.js `getContext` function
See original GitHub issueDescribe the bug
Whenever the prepare
function of src/setup.js
returns anything (headers, etc.), the HTTP endpoint causes an Error: Transferred a partial file.
This does not happen if the prepare
function is not present or does not return anything.
Logs
There is not much to see here. I’ve only tested the endpoints using Insomnia, so no browser logs. (Though, I suspect there wouldn’t be any aside from the aforementioned partial fire error.)
yarn run v1.22.5
warning package.json: No license field
$ svelte-kit dev
(node:83958) ExperimentalWarning: The ESM module loader is experimental.
> Listening on http://localhost:3000
To Reproduce The issue happens after a fresh install of Kit. My setup options were to disable TS in components, and to use SCSS for preprocessing.
I’ve made a repo to show exactly where the issue occurs: @didier/svelte-kit-broken-endpoints. See src/setup.js
for an example.
Expected behavior
I would expect the endpoint to send a respond, irregardless of whatever the prepare
function does and returns.
Stacktraces
None, no visible errors occur besides the HTTP client warning me of the Error: Transferred a partial file
.
Information about your SvelteKit Installation:
System:
OS: macOS 11.2.3
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 156.12 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.17.0 - ~/.nvm/versions/node/v12.17.0/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.17.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Brave Browser: 89.1.21.77
Firefox: 83.0
Firefox Developer Edition: 85.0
Firefox Nightly: 74.0a1
Safari: 14.0.3
npmPackages:
@sveltejs/kit: ^1.0.0-next.55 => 1.0.0-next.55
svelte: ^3.29.0 => 3.35.0
Severity This issue is blocking usage of SvelteKit entirely, as HTTP Endpoints are part of the core functionality.
Additional context I’ve had contact with @antony about this. Raising the issue here so other contributors can take a look.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Closing since
getContext
no longer returns a response header, andhandle
takes in arequest
object instead, so there’s no longer a header -> header function signature.Note that
prepare
has been replaced bygetContext
: https://kit.svelte.dev/docs#hooks