Skip to content

Commit

Permalink
Skip hot reload sync event
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jul 5, 2023
1 parent 31dee6f commit 0955263
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 16 deletions.
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

0 comments on commit 0955263

Please sign in to comment.