Open alexbjorlig opened 3 weeks ago
What are you using platform
for? It's only defined for edge functions, because its only member, context
, is only available within edge functions (settable through the runtime
adapter option). The only member of context
is waitUntil
, which you can now import directly in both edge and serverless functions: https://vercel.com/changelog/waituntil-is-now-available-for-vercel-functions
@Rich-Harris should we "shim" this for serverless, by passing along a "fake" context on which we provide the waitUntil
method? I tend towards "no, use the package Vercel provides directly". If you're using platform
you're already provider-specific.
What are you using
platform
for? It's only defined for edge functions, because its only member,context
, is only available within edge functions. The only member ofcontext
iswaitUntil
, which you can now import directly in both edge and serverless functions: https://vercel.com/changelog/waituntil-is-now-available-for-vercel-functions@Rich-Harris should we "shim" this for serverless, by passing along a "fake" context on which we provide the
waitUntil
method? I tend towards "no, use the package Vercel provides directly". If you're usingplatform
you're already provider-specific.
It was exactly waitUntil
. Ok, so the recommended approach is to import it from here import { waitUntil } from '@vercel/functions'
?
I'm not sure why, but I was under the impression that such thing should live on the "platform", but importing from @vercel/functions
would also be ok.
I tend towards "no, use the package Vercel provides directly"
I lean the same way - it would just add code to people's bundles if they weren't using it. For consistency it might even be better to remove it from edge functions? (deprecate with warning first, obvs)
Ok, so the recommended approach is to import it from here import { waitUntil } from '@vercel/functions'?
Exactly
I'm not sure why, but I was under the impression that such thing should live on the "platform"
platform
is more for things that are per-request and coming from the underlying platform. But yeah it's not very strict what's coming from where. In this case, since Vercel provides it, it's better to use the package directly.
For consistency it might even be better to remove it from edge functions? (deprecate with warning first, obvs)
Makes sense
Isn't it already populated here? https://github.com/sveltejs/kit/blob/f67898d25ee32e9377221979d2a9e6b792786f4e/packages/adapter-vercel/files/edge.js#L13-L24 The ambient type for it exists too although it's not correctly included when importing the adapter at the moment. https://github.com/sveltejs/kit/blob/f67898d25ee32e9377221979d2a9e6b792786f4e/packages/adapter-vercel/ambient.d.ts#L1-L12 Or am I mistaken and thinking of something entirely different?
It's there, but it's only set for edge functions, not serverless functions, hence the confusion and thought to remove the context for edge, since it only contains waitUntil
. Argument against it is that at some point in the future there might be other things on the context object and we would go adding it back in again - which makes me think we just leave everything as is and close this issue.
Describe the bug
When I deploy my project on Vercel, this line gives undefined:
Do I need to do something different?
My
svelte.config.js
looks like this:I also tried adding a console.log in
src/hooks.server.ts
like this:But this was also undefined?
Reproduction
repo to clone is here.
Deployed vercel project is here.
Logs
Severity
annoyance
Additional Information