Skip to content

Netlify Edge functions context is not available locally #4908

Closed
@brittneypostma

Description

@brittneypostma

Describe the bug

When edge: true is set in the svelte.config.js file, the event.platform.context can only be seen on a deployed site. On sveltekit's port it is underfined and running ntl dev gets an empty object which does mean that it exists, however it is not a great dev experience for testing and creating edge functions. I would like to see the same thing locally as the deployed application shows. I'm unsure if this problem lies in the adapter or in ntl dev but figured I would start here.

Reproduction

Repo: https://github.com/brittneypostma/sveltekit-on-the-edge

  • Run pnpm run dev at localhost:3000, undefined is shown on the / route. No errors in console, but warning about expected prop ctx not being present.
  • Run ntl dev at localhost:8888, {} is shown on the / route. There are 4 errors in the console, all 404s about resources not being found. I posted these in the logs below.
  • Deploy site to Netlify and full ctx object is present on the / route. No errors in console.

Logs

Failed to load resource: the server responded with a status of 404 (Not Found)

start-b2afe8b6.js:1 
index-dd64db13.js:1 
__layout.svelte-0d57de41.js:1 
index.svelte-9a34a6ed.js:1

System Info

System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 689.52 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Firefox Developer Edition: 101.0
    Safari: 15.4
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.40 
    @sveltejs/adapter-netlify: 1.0.0-next.56 => 1.0.0-next.56 
    @sveltejs/kit: next => 1.0.0-next.326 
    svelte: ^3.44.0 => 3.48.0

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions