Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When deployed to vercel sveltekit endpoints have body set to undefined #1143

Closed
ivoreis opened this issue Apr 20, 2021 · 0 comments · Fixed by #1146
Closed

When deployed to vercel sveltekit endpoints have body set to undefined #1143

ivoreis opened this issue Apr 20, 2021 · 0 comments · Fixed by #1146

Comments

@ivoreis
Copy link
Contributor

ivoreis commented Apr 20, 2021

Describe the bug
Running an app and hosting in Vercel (using vercel-adapter) when data is posted to an endpoint containing non-empty body, the req object contains body set to undefined.

Can't reproduce this locally.

  • Running npm run dev works as expected.
  • Running npm run build && npm run start works as expected.
  • Running vercel dev works as expected.

One thing I've noticed is that the req payload in this @svelkit/kit version should already return both body and rawBody but somehow the code deployed to Vercel doesn't return rawBody.

Running latest adapter-vercel:

    "@sveltejs/adapter-vercel": {
      "version": "1.0.0-next.13",
      "resolved": "https://registry.npmjs.org/@sveltejs/adapter-vercel/-/adapter-vercel-1.0.0-next.13.tgz",
      "integrity": "sha512-7/DvjGBW+ldK80E7TsIB3Vpo6QmhdKK1+6pnN3/HrB1Uc+12sxvI76sXQGV0qhcJR3wUdXlHed3p8A8TSx1RhA==",
      "dev": true,
      "requires": {
        "@sveltejs/kit": "1.0.0-next.81",
        "esbuild": "^0.11.12"
      },
      "dependencies": {
        "@sveltejs/kit": {
          "version": "1.0.0-next.81",
          "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.0.0-next.81.tgz",
          "integrity": "sha512-v1CxkLYX3xXRdihvpiOOuQs2MZa/f3ENZKeX7sMYDKQ0MzRpmrhzmplVukYD+fZHYUFjMj+yKYPMhOpC/p3ckQ==",
          "dev": true,
          "requires": {
            "@sveltejs/vite-plugin-svelte": "^1.0.0-next.7",
            "cheap-watch": "^1.0.3",
            "sade": "^1.7.4"
          }
        },
        "esbuild": {
          "version": "0.11.12",
          "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.12.tgz",
          "integrity": "sha512-c8cso/1RwVj+fbDvLtUgSG4ZJQ0y9Zdrl6Ot/GAjyy4pdMCHaFnDMts5gqFnWRPLajWtEnI+3hlET4R9fVoZng==",
          "dev": true
        }
      }
    },

Logs

[POST] /api/reply.json
09:22:19:85
{
  method: 'POST',
  path: '/api/reply.json',
  query: URLSearchParams {},
  body: undefined,
  host: 'svelte-vercel-body.vercel.app',
  params: {},
  context: {}
}

To Reproduce


Request:

POST https://svelte-vercel-body.vercel.app/api/reply.json HTTP/1.1
Content-Type: application/json

{
  "message": "empty body"
}


Response:

{
  "message": {
    "method": "POST",
    "path": "/api/reply.json",
    "query": {},
    "host": "svelte-vercel-body.vercel.app",
    "params": {},
    "context": {}
  }
}

Sample project - https://github.com/ivoreis/svelte-vercel-body

Information about your SvelteKit Installation:

Diagnostics

$ npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browser
npx: installed 1 in 1.186s

System:
OS: macOS 11.2.3
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 292.50 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.3 - /usr/local/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.14.9 - /usr/local/bin/npm
npmPackages:
@sveltejs/kit: next => 1.0.0-next.84
svelte: ^3.29.0 => 3.37.0
vite: ^2.1.0 => 2.2.1

Browser: Chrome, Safari, Edge, CURL

Severity
How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of SvelteKit entirely?

Note: the more honest and specific you are here the more we will take you seriously.

Non-blocking and I'm aware this tool is a WIP 😊

Please let me know if there's any other detail need and/or anything I can help with.

Additional context
Add any other context about the problem here.

@Rich-Harris Do you think body (https://github.com/sveltejs/kit/blob/master/packages/adapter-vercel/files/entry.js#L15) should be rawBody instead?

Following the code I see https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/server/parse_body/index.js#L5-L6 being used by SSR (https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/server/index.js#L24) but I'm not familiar with the code to say for certain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant