uncaughtException: TypeError: res.once is not a function
See original GitHub issueRun next info
(available from version 12.0.8 and up)
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:20 PDT 2021; root:xnu-7195.141.6~3/RELEASE_ARM64_T8101
Binaries:
Node: 16.13.2
npm: 8.1.2
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.0.9
react: 17.0.2
react-dom: 17.0.2
What version of Next.js are you using?
12.0.9
What version of Node.js are you using?
16.13.2
What browser are you using?
Chrome
What operating system are you using?
macOS(Apple Silicon)
How are you deploying your application?
next start, but this is occurred local.
Describe the Bug
I use custom server only local to use https. I upgraded Next.js from 11.1.2 to 12.0.9. Then, when I reload once, browser no longer finishes loading. And I got this error.
error - uncaughtException: TypeError: res.once is not a function
Expected Behavior
To finish reloading with no error.
To Reproduce
- Set
server.js
,./certificates/default.key
and./certificates/default.crt
- Change package.json
"scripts": {
"dev": "node ./server.js",
...
},
yarn dev
- Load browser at the first time is success( but error has appeared )
- Reload browser
- never ending reload with error
This is my server.js.
const { createServer } = require('https')
const { parse } = require('url')
const next = require('next')
const fs = require('fs')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const httpsOptions = {
key: fs.readFileSync('./certificates/default.key'),
cert: fs.readFileSync('./certificates/default.crt')
}
app.prepare().then(() => {
createServer(httpsOptions, (req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
}).listen(3000, err => {
if (err) throw err
})
})
Additional Context
it works on Next.js 11.1.2.
So, ./certificates/default.key
and ./certificates/default.crt
are no problem.
I need to use https at local because I develop PWA with next-pwa 5.4.4.
I think probably RequestHandler become not to be able to handle res
of argument of callback function of createServer
of https
on Next.js 12?
Or this may be related https://nextjs.org/docs/upgrading#nextjs-hmr-connection-now-uses-a-websocket.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Node.js res.send is not a function - Stack Overflow
I'm trying the following code but it's giving me an error, "res.send is not a function ...
Read more >Node.js Connector TypeError: res.status is not a function
status is not a function. I am learning JS scripting and am making a RESTful API with the MariaDB Node. js Connector and...
Read more >How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >JavaScript TypeErrors and Techniques to Prevent Them
A short guide on best practices, techniques and existing tooling available to prevent TypeErrors in JavaScript or TypeScript.
Read more >How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We use sentry in our project, which we nailed down to be breaking with the latest release of next v12.0.9 - maybe this is the case for you too.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.