Commit dedd4acb authored by Jimmy Lai's avatar Jimmy Lai

Arm instant navigation lock immediately

parent eeb0a2b7
// imports polyfill from `@next/polyfill-module` after build.
import '../build/polyfills/polyfill-module'
declare global {
interface Window {
__NEXT_ARM_INSTANT_NAVIGATION_LOCK?: () => void
}
}
// Only set up devtools for the dev server.
if (process.env.__NEXT_DEV_SERVER) {
require('../next-devtools/userspace/app/app-dev-overlay-setup') as typeof import('../next-devtools/userspace/app/app-dev-overlay-setup')
......@@ -10,7 +16,11 @@ if (process.env.__NEXT_DEV_SERVER) {
// (e.g. Playwright) sets/clears this cookie to control the navigation lock.
// Browser-only.
if (process.env.__NEXT_EXPOSE_TESTING_API && typeof window !== 'undefined') {
const { startListeningForInstantNavigationCookie } =
const {
startListeningForInstantNavigationCookie,
armNavigationLockForTesting,
} =
require('./components/segment-cache/navigation-testing-lock') as typeof import('./components/segment-cache/navigation-testing-lock')
startListeningForInstantNavigationCookie()
window.__NEXT_ARM_INSTANT_NAVIGATION_LOCK = armNavigationLockForTesting
}
......@@ -81,6 +81,12 @@ function acquireLock(): void {
lockState = { promise, resolve: resolve! }
}
export function armNavigationLockForTesting(): void {
if (process.env.__NEXT_EXPOSE_TESTING_API) {
acquireLock()
}
}
function releaseLock(): void {
if (lockState !== null) {
lockState.resolve()
......
......@@ -52,6 +52,8 @@ export function InstantNavsPanel() {
}
function handleStartClientNav() {
window.__NEXT_ARM_INSTANT_NAVIGATION_LOCK?.()
if (typeof cookieStore !== 'undefined') {
cookieStore.set({
name: COOKIE_NAME,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment