Open eashish93 opened 1 year ago
I'm seeing this as well. It's possible that it's the underlying cause of a bigger headache -- that the dev server just hangs after navigating to/compiling a certain number of routes. I suspect this is due to the exhaustion of connections to the database I'm using.
Dev server hanging issue: https://github.com/vercel/next.js/issues/10061#issuecomment-1293639510 https://github.com/vercel/next.js/issues/10061#issuecomment-1616037310
@zerosym sounds unrelated. That's a very old issue though, might be worth opening a new one with a minimal(!) reproduction instead.
@balazsorban44, It's related to dev server hang and you can try it with mongodb example or with firebase auth (app dir). Works fine witb pages dir though and no server hang.
@balazsorban44 Old discussion thread that shows how persistent globals and database connection issues (which I believe cause at least some of the dev server hangs) are intertwined:
https://github.com/vercel/next.js/discussions/26427#discussioncomment-4796502
The comment I linked to points out that the issue still occurs with next13's appdir, but then goes on to say that using globalThis
fixes that, a solution which is no longer working. Seems like every request triggers compilation in a new process? At least that's what it looks like when logging statements.
For example:
{"level":30,"time":1688654748166,"pid":127,"hostname":"example","app":"web","msg":"Initializing service: client -- already exists? no"}
{"level":30,"time":1688654748365,"pid":134,"hostname":"example","app":"web","msg":"Initializing service: client -- already exists? no"}
Same issue as #47099 i think
The same problem occurring will result in too many database connections.
We're getting the same issue, app directory with Prisma. No combination of global, globalThis, etc, cacheing of the PrismaClient seems to work for us.
Is there any update?
+1 I'm also running into this issue myself and globalThis
doesn't work
@balazsorban44 Old discussion thread that shows how persistent globals and database connection issues (which I believe cause at least some of the dev server hangs) are intertwined:
The comment I linked to points out that the issue still occurs with next13's appdir, but then goes on to say that using
globalThis
fixes that, a solution which is no longer working. Seems like every request triggers compilation in a new process? At least that's what it looks like when logging statements.For example:
{"level":30,"time":1688654748166,"pid":127,"hostname":"example","app":"web","msg":"Initializing service: client -- already exists? no"} {"level":30,"time":1688654748365,"pid":134,"hostname":"example","app":"web","msg":"Initializing service: client -- already exists? no"}
In my case, the workaround solution does not work anymore
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/unruffled-meadow-88lfjk
To Reproduce
Try this in any
page.js|tsx
file:Describe the Bug
Global variable not preserving on app directory and app route handler. Working fine on pages directory. On full/hot reloading multiple times the above page.tsx it's printing
undefined
every time.Expected Behavior
On hot/full reloading multiple times, it should log pattern like this:
Which browser are you using? (if relevant)
Chrome 114
How are you deploying your application? (if relevant)
No response
NEXT-1402