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

skip hot reload sync event for applying hmr updates #52270

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ function processMessage(
)

const isHotUpdate =
obj.action !== 'sync' ||
((!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== '/_error') &&
isUpdateAvailable())
obj.action !== 'sync' &&
(!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== '/_error') &&
isUpdateAvailable()

// Attempt to apply hot updates or reload.
if (isHotUpdate) {
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/app-dir/metadata/app/api/manifest/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function GET() {
return new Response('{ "name": "metadata-app", }', {
headers: {
'Content-Type': 'application/xml; charset=utf-8',
},
})
}
7 changes: 7 additions & 0 deletions test/e2e/app-dir/metadata/app/api/preload/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function GET() {
return new Response('console.log("hello from preload")', {
headers: {
'Content-Type': 'application/javascript; charset=utf-8',
},
})
}
4 changes: 1 addition & 3 deletions test/e2e/app-dir/metadata/app/api/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { NextResponse } from 'next/server'

export function GET() {
return new NextResponse('hello api route')
return new Response('hello api route')
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/metadata/app/basic-edge/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ReactDOM from 'react-dom'
// NOTE: atm preload/prefetch/prefetchDNS are only supported in the SSR and client, not in RSC yet
export default function Client() {
// @ts-ignore
ReactDOM.preload('/preload-url', { as: 'script' })
ReactDOM.preload('/api/preload', { as: 'script' })
// @ts-ignore
ReactDOM.preconnect('/preconnect-url', { crossOrigin: 'use-credentials' })
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/metadata/app/basic-edge/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const metadata: Metadata = {
authors: [{ name: 'huozhi' }, { name: 'tree', url: 'https://tree.com' }],
themeColor: { color: 'cyan', media: '(prefers-color-scheme: dark)' },
colorScheme: 'dark',
manifest: 'https://www.google.com/manifest',
manifest: '/api/manifest',
viewport: {
width: 'device-width',
initialScale: 1,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/metadata/app/basic/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ReactDOM from 'react-dom'
// NOTE: atm preload/prefetch/prefetchDNS are only supported in the SSR and client, not in RSC yet
export default function Client() {
// @ts-ignore
ReactDOM.preload('/preload-url', { as: 'script' })
ReactDOM.preload('/api/preload', { as: 'script' })
// @ts-ignore
ReactDOM.preconnect('/preconnect-url', { crossOrigin: 'use-credentials' })
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/metadata/app/basic/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const metadata: Metadata = {
authors: [{ name: 'huozhi' }, { name: 'tree', url: 'https://tree.com' }],
themeColor: { color: 'cyan', media: '(prefers-color-scheme: dark)' },
colorScheme: 'dark',
manifest: 'https://www.google.com/manifest',
manifest: '/api/manifest',
viewport: {
width: 'device-width',
initialScale: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default function Page() {
to /
</Link>
<br />
<Link href="/basic" id="to-basic">
{/* <Link href="/basic" id="to-basic">
to /basic
</Link>
</Link> */}
</>
)
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/app-dir/metadata/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ createNextDescribe(
})

await matchMultiDom('link', 'rel', 'href', {
manifest: 'https://www.google.com/manifest',
manifest: '/api/manifest',
author: 'https://tree.com',
preconnect: '/preconnect-url',
preload: '/preload-url',
preload: '/api/preload',
'dns-prefetch': '/dns-prefetch-url',
})

Expand Down Expand Up @@ -251,10 +251,10 @@ createNextDescribe(
})

await matchMultiDom('link', 'rel', 'href', {
manifest: 'https://www.google.com/manifest',
manifest: '/api/manifest',
author: 'https://tree.com',
preconnect: '/preconnect-url',
preload: '/preload-url',
preload: '/api/preload',
'dns-prefetch': '/dns-prefetch-url',
})

Expand Down