Skip to content

TypeError in 13.3.2-canary.7: Cannot read properties of undefined (reading 'current') error. #48869

@dincerpece

Description

@dincerpece

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.15.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.3.2-canary.7
      eslint-config-next: 13.3.1
      react: 18.2.0
      react-dom: 18.2.0

Which example does this report relate to?

there is no

What browser are you using? (if relevant)

Chrome 112.0.5615.138

How are you deploying your application? (if relevant)

localhost

Describe the Bug

While there is no problem in the pages that do not contain a subpage such as contact-us in the src/app directory, I get the error "error - TypeError: Cannot read properties of undefined (reading 'current')" in the pages under the news-media/[slug] folder. This error also happens on my page in news-media/[slug]. When I do next build and then next start, I don't get such errors in localhost:3000, but I get these errors in my own configuration "next build && node server/server.js production".

My server.js file looks like this: "const { createServer } = require('https')
const { parse } = require('url')
const next = require('next')
const fs = require('fs')
const dev = process.argv[2] !== 'production'
const serverProduct = process.argv[3] === 'server' || undefined

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
const hostname = 'localhost'
const port = 443
// when using middleware hostname and port must be provided below
const app = next({ dev, hostname, port })
const handle = app.getRequestHandler()
const httpsOptions = {
key: fs.readFileSync(./server/certificates/${serverProduct ? 'cloudflare.key' : 'server.key'}),
cert: fs.readFileSync(./server/certificates/${serverProduct ? 'cloudflare.pem' : 'server.crt'}),
}
app.prepare().then(() => {
createServer(httpsOptions, async (req, res) => {
try {
const parsedUrl = parse(req.url, true)
await handle(req, res, parsedUrl).then(null)
} catch (err) {
console.error('Error occurred handling', req.url, err)
res.statusCode = 500
res.end('internal server error')
}
})
.once('error', (err) => {
console.error(err)
process.exit(1)
})
.listen(port, () => {
console.log(> Ready on https://${hostname})
})
})
"
Screenshot_17

Expected Behavior

What is missing in my server.js file or what do I need to do last 13.3.2-canary.7 I got this error. Normally, the pages under news-media/[slug] open, but when I refresh the page, I get the error "TypeError: Cannot read properties of undefined (reading 'current') 500 Internal Server Error.
"

To Reproduce

I deleted node_modules and reinstalled the packages with npm. I deleted the .next folder and it still didn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    examplesIssue was opened via the examples template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions