mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? When running a [multi-zone](https://github.com/vercel/next.js/tree/canary/examples/with-zones) app in dev, guest app pages would infinitely reload if you change the basePath of the host app to the default one (omit basePath settings in next.config.js) (empty string `""` as per Next.js docs). ### Why? The HMR upgrade request would fail and get caught into a retry loop. In the multi-zone case, they fail because the upgrade request would be sent again for a request that had already been upgraded. This resulted in a "server.handleUpgrade() was called more than once with the same socket" error, causing the upgrade request to fail. Every time a retry occurred, the page would trigger a full refresh since certain HMR errors cause the browser to reload. ### How? This ensures the upgrade handler only responds to requests that match the configured basePath (considering when there is no basePath). Default basePath for Next.js applications it's an empty string `""`. Ref: https://nextjs.org/docs/app/api-reference/next-config-js/basePath Other fixes & updates related to the bug: - Updated test apps to avoid having issues regarding client & server mismatch for dates - Added default use case in e2e tests, where you have a default Next.js application where the basePath it's the default one and a guest app that it's being routed by the main one through Next.js rewrites. Closes NEXT-1797 Fixes #59161 Fixes #56615 Fixes #54454 --------- Co-authored-by: Zack Tanner <[email protected]>
20 lines
396 B
TypeScript
20 lines
396 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
export default function Page() {
|
|
const [date, setDate] = useState<Number>()
|
|
|
|
useEffect(() => {
|
|
setDate(Date.now())
|
|
}, [])
|
|
|
|
// this variable is edited by the test to verify HMR
|
|
const editedContent = ''
|
|
return (
|
|
<>
|
|
<p>hello from host app</p>
|
|
<div>{editedContent}</div>
|
|
<div id="now">{`${date}`}</div>
|
|
</>
|
|
)
|
|
}
|