Skip to content

Nextjs 13 / Cypress: TypeError: Cannot convert undefined or null to object #6059

@geryit

Description

@geryit

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.16.0

Framework Version

7.16.0

Link to Sentry event

No response

Steps to Reproduce

We upgraded to Nextjs 13 and @sentry/nextjs to 7.16.0 yesterday and started to see this in CircleCI on Cypress job:

/home/circleci/project/node_modules/@sentry/nextjs/cjs/utils/instrumentServer.js:77
      const serverPrototype = Object.getPrototypeOf(liveServer);
                                     ^

TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at NextServer.wrappedHandlerGetter (/home/circleci/project/node_modules/@sentry/nextjs/cjs/utils/instrumentServer.js:77:38)
    at /home/circleci/project/node_modules/next/dist/server/next.js:78:47
    at Server.<anonymous> (/home/circleci/project/node_modules/next/dist/server/lib/start-server.js:17:16)
    at Server.emit (node:events:513:28)
    at Server.emit (node:domain:489:12)
    at parserOnIncoming (node:_http_server:998:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
Error: server closed unexpectedly
    at ChildProcess.onClose (/home/circleci/project/node_modules/start-server-and-test/src/index.js:75:14)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1
CircleCI received exit code 1

Expected Result

No errors so Cypress doesn't exit

Actual Result

/home/circleci/project/node_modules/@sentry/nextjs/cjs/utils/instrumentServer.js:77
      const serverPrototype = Object.getPrototypeOf(liveServer);
                                     ^

TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at NextServer.wrappedHandlerGetter (/home/circleci/project/node_modules/@sentry/nextjs/cjs/utils/instrumentServer.js:77:38)
    at /home/circleci/project/node_modules/next/dist/server/next.js:78:47
    at Server.<anonymous> (/home/circleci/project/node_modules/next/dist/server/lib/start-server.js:17:16)
    at Server.emit (node:events:513:28)
    at Server.emit (node:domain:489:12)
    at parserOnIncoming (node:_http_server:998:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
Error: server closed unexpectedly
    at ChildProcess.onClose (/home/circleci/project/node_modules/start-server-and-test/src/index.js:75:14)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1
CircleCI received exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions