Skip to content

Cannot use 'in' operator to search for 'Symbol(h3ParsedBody)' in undefined Vercel serveless function #15217

@mroddev

Description

@mroddev

Environment


  • Operating System: Windows_NT
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.12
  • Nitro Version: 0.6.0
  • Package Manager: unknown
  • Builder: vite
  • User Config: ssr, runtimeConfig, modules, strapi, vite, css, build, serverHandlers
  • Runtime Modules: @pinia/nuxt@0.4.3, @nuxtjs/strapi@1.6.1
  • Build Modules: -

Reproduction

Reproduction: https://github.com/marcorodriguesdev/nuxt-app

Steps to reproduce:

  • Deploy repo to Vercel using the env variable: NITRO_PRESET=vercel-edge;
  • Do a simple form submit;
  • Check Vercel Functions realtime logs and you will see the error "Cannot use 'in' operator to search for 'Symbol(h3ParsedBody)' in undefined"

Describe the bug

When deploying a Nuxt 3 app on Vercel, with a serverless function to simply read the body (contact form data) of the Post request, I'm getting the following error on Vercel Realtime Logs:
"[POST] /api/contact

TypeError: Cannot use 'in' operator to search for 'Symbol(h3ParsedBody)' in undefined
at readBody (/var/task/node_modules/h3/dist/index.cjs:180:24)
at /var/task/api/contact.js:58:24
at Server. (/var/task/___vc/__helpers.js:813:19)
at Server.emit (node:events:527:28)
at parserOnIncoming (node:_http_server:956:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
2022-10-20T19:23:57.162Z 39ca0d68-7c70-4256-8234-076f35415a2d Task timed out after 10.01 seconds"

This is the code that it runs:

export default defineEventHandler(async (event) => {
  try {
    const body = await readBody(event);

    return {
      body,
    };
  } catch (err) {
    console.log(err);
  }
});

Additional context

Code works fine locally.
Vercel env variable is set to NITRO_PRESET=vercel-edge

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions