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

Server crash in Next.js with invalid api route URI and dd-trace #1898

Closed
jakst opened this issue Mar 8, 2022 · 0 comments · Fixed by #1929
Closed

Server crash in Next.js with invalid api route URI and dd-trace #1898

jakst opened this issue Mar 8, 2022 · 0 comments · Fixed by #1929
Labels
bug Something isn't working integration-nextjs issues relating to the Next.js framework from Vercel

Comments

@jakst
Copy link

jakst commented Mar 8, 2022

Describe the bug

The crash happens under the following circumstances:

  • There is a Next.js catch all page route, like pages/[...catchAll].js
  • The Next.js server is started with dd-trace running, like this NODE_OPTIONS='--require ./datadog' next start and datadog.js has this content: require('dd-trace').init(). This applies to any version of dd-trace between 1.2.0 and the latest 2.3.1.
  • There is a request to an api route with an invalid URI /api/%ff.

It produces the following stack trace from Next.js

./node_modules/next/dist/shared/lib/router/utils/route-matcher.js:18
                throw new _utils.DecodeError('failed to decode param');
                      ^
DecodeError: failed to decode param
    at decode (./node_modules/next/dist/shared/lib/router/utils/route-matcher.js:18:23)
    at ./node_modules/next/dist/shared/lib/router/utils/route-matcher.js:26:80
    at Array.map (<anonymous>)
    at ./node_modules/next/dist/shared/lib/router/utils/route-matcher.js:26:67
    at Array.forEach (<anonymous>)
    at Object.match (./node_modules/next/dist/shared/lib/router/utils/route-matcher.js:22:29)
    at NextNodeServer.handleApiRequest (./node_modules/next/dist/server/base-server.js:538:39)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.

I don't know whether the actual error is in next.js or in dd-trace, but they are both black boxes to me and I only get a stack trace containing next.js code. I have cross posted this in the Next.js repo: vercel/next.js#35132

Environment

  • Operation system: MacOS v12.2.1
  • Node version: v16.14
  • Tracer version: v1.2.0 up to v2.3.1
  • Agent version: Not relevant

To reproduce

@jakst jakst added the bug Something isn't working label Mar 8, 2022
@bengl bengl added the integration-nextjs issues relating to the Next.js framework from Vercel label Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working integration-nextjs issues relating to the Next.js framework from Vercel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants