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

res.once is not a function #4463

Closed
1 of 5 tasks
WahidN opened this issue Jan 27, 2022 · 2 comments · Fixed by #4467
Closed
1 of 5 tasks

res.once is not a function #4463

WahidN opened this issue Jan 27, 2022 · 2 comments · Fixed by #4467

Comments

@WahidN
Copy link

WahidN commented Jan 27, 2022

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other: @sentry/nextjs

Version:

6.17.2

Description

I get the following error whenever I get an error in nextjs (12.0.8)

TypeError: res.once is not a function
    at Domain.<anonymous> (/Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js:170:33)
    at Domain.run (node:domain:378:15)
    at DevServer.<anonymous> (/Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js:148:23)
    at step (/Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/node_modules/tslib/tslib.js:141:27)
    at Object.next (/Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/node_modules/tslib/tslib.js:122:57)
    at /Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/node_modules/tslib/tslib.js:115:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/node_modules/tslib/tslib.js:111:16)
    at DevServer.wrappedReqHandler [as handleRequest] (/Users/user/Documents/Projecten/user/project/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js:139:24)
    at DevServer.<anonymous> (/Users/user/Documents/Projecten/user/rproject/node_modules/next/dist/server/next-server.js:403:20)

Code in the file thats causing the error

 res.once('finish', function () {
                                var transaction = tracing_1.getActiveTransaction();
                                if (transaction) {
                                    transaction.setHttpStatus(res.statusCode);
                                    // we'll collect this data in a more targeted way in the event processor we added above,
                                    // `addRequestDataToEvent`
                                    delete transaction.metadata.requestPath;
                                    // Push `transaction.finish` to the next event loop so open spans have a chance to finish before the
                                    // transaction closes
                                    setImmediate(function () {
                                        transaction.finish();
                                    });
                                }
                            });
@WahidN
Copy link
Author

WahidN commented Jan 27, 2022

There is a pull request for this
fix(nextjs): TypeError: res.once is not a function

@WahidN WahidN closed this as completed Jan 27, 2022
lobsterkatie added a commit that referenced this issue Jan 28, 2022
…erver (#4467)

In vercel/next.js#32999 (released as part of 12.0.9), Next.js made an internal change, so that it now wraps the raw `http.IncomingMessage` and `http.ServerResponse` objects which get passed to the main server request handler in `NodeNextRequest` and `NodeNextResponse` objects, respectively. We therefore need to unwrap them before we can use them.

This does that unwrapping (if necessary; older versions of nextjs still don't need it) and fixes the relevant types.

Fixes #4463
Fixes vercel/next.js#33726
@AbhiPrasad
Copy link
Member

Fixed in https://www.npmjs.com/package/@sentry/nextjs/v/6.17.3. If anything else comes up, please let us know!

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.

2 participants