Unverified Commit 2256b6be authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Properly handle hanging promise rejections during prerendering (#81754)

We are using hanging promises for excluding request-specific data from a
prerender. When prerendering is aborted, we reject all hanging promises.
In dev mode, React uses these rejections to construct more detailed
owner stacks. This allows us to provide better errors during the
prerender validation.

For this to work reliably, we need to ensure that all hanging promises
are rejected after React's rendering is aborted. However, some hanging
promises are created before React starts rendering (when creating the
RSC component tree). Furthermore, for memory reasons, the first hanging
promise adds a single abort listener that's shared with all subsequent
hanging promises (see #77480). In this case, the shared abort listener
for rejections is added before React can add its own abort listener.

When using the same abort signal for both the React render and the
hanging promises, the hanging promises would be rejected too early,
preventing React from properly constructing the owner stacks.

To ensure that the order of operations is correct, we now use a separate
abort signal for React's rendering that is aborted before the "render
signal" [^1], which is used by the hanging promises, is aborted. For
parity, we're doing this not only in dev mode but also in production
mode, so that the hanging promise rejection handling is always the same.

Technically, I don't think this change is necessary for the SSR
prerender pass, but it felt cleaner to apply it there as well. However,
we could revisit that when we properly split the two prerender stores.
For example, the `cacheSignal` and `prerenderResumeDataCache` also don't
need to be present on the client prerender store.

Reverts #81501.

[^1]: This is an unfortunate name clash. We could also call this one
"cache signal", which would be in line with `React.cacheSignal()` – its
potential successor. But that clashes with our current `cacheSignal`,
which tracks the cache reads. We might revisit this naming problem in a
future PR.
parent 8abbb3dc
......@@ -711,6 +711,7 @@ async function warmupDevRender(
const renderController = new AbortController()
const prerenderController = new AbortController()
const reactController = new AbortController()
const cacheSignal = new CacheSignal()
const prerenderStore: PrerenderStore = {
......@@ -760,6 +761,7 @@ async function warmupDevRender(
// We unset the cache so any late over-run renders aren't able to write into this cache
prerenderStore.prerenderResumeDataCache = null
// Abort the render
reactController.abort()
renderController.abort()
// We don't really want to return a result here but the stack of functions
......@@ -2314,19 +2316,30 @@ async function spawnDynamicValidationInDev(
NEXT_HMR_REFRESH_HASH_COOKIE
)?.value
// Prerender controller represents the lifetime of the prerender.
// It will be aborted when a Task is complete or a synchronously aborting
// API is called. Notably during cache-filling renders this does not actually
// terminate the render itself which will continue until all caches are filled
// The prerender controller represents the lifetime of the prerender. It will
// be aborted when a task is complete or a synchronously aborting API is
// called. Notably, during prospective prerenders, this does not actually
// terminate the prerender itself, which will continue until all caches are
// filled.
const initialServerPrerenderController = new AbortController()
// This controller represents the lifetime of the React render call. Notably
// during the cache-filling render it is different from the prerender controller
// because we don't want to end the react render until all caches are filled.
// This controller is used to abort the React prerender.
const initialServerReactController = new AbortController()
// This controller represents the lifetime of the React prerender. Its signal
// can be used for any I/O operation to abort the I/O and/or to reject, when
// prerendering aborts. This includes our own hanging promises for accessing
// request data, and for fetch calls. It might be replaced in the future by
// React.cacheSignal(). It's aborted after the React controller, so that no
// pending I/O can register abort listeners that are called before React's
// abort listener is called. This ensures that pending I/O is not rejected too
// early when aborting the prerender. Notably, during the prospective
// prerender, it is different from the prerender controller because we don't
// want to end the React prerender until all caches are filled.
const initialServerRenderController = new AbortController()
// The cacheSignal helps us track whether caches are still filling or we are ready
// to cut the render off.
// The cacheSignal helps us track whether caches are still filling or we are
// ready to cut the render off.
const cacheSignal = new CacheSignal()
const captureOwnerStackClient = React.captureOwnerStack
......@@ -2407,16 +2420,26 @@ async function spawnDynamicValidationInDev(
// We don't want to stop rendering until the cacheSignal is complete so we pass
// a different signal to this render call than is used by dynamic APIs to signify
// transitioning out of the prerender environment
signal: initialServerRenderController.signal,
signal: initialServerReactController.signal,
}
)
// The listener to abort our own render controller must be added after React
// has added its listener, to ensure that pending I/O is not aborted/rejected
// too early.
initialServerReactController.signal.addEventListener(
'abort',
() => {
initialServerRenderController.abort()
},
{ once: true }
)
// Wait for all caches to be finished filling and for async imports to resolve
trackPendingModules(cacheSignal)
await cacheSignal.cacheReady()
initialServerRenderController.abort()
initialServerPrerenderController.abort()
initialServerReactController.abort()
// We don't need to continue the prerender process if we already
// detected invalid dynamic usage in the initial prerender phase.
......@@ -2438,7 +2461,7 @@ async function spawnDynamicValidationInDev(
)
} catch (err) {
if (
initialServerRenderController.signal.aborted ||
initialServerReactController.signal.aborted ||
initialServerPrerenderController.signal.aborted
) {
// These are expected errors that might error the prerender. we ignore them.
......@@ -2453,8 +2476,10 @@ async function spawnDynamicValidationInDev(
}
if (initialServerResult) {
const initialClientRenderController = new AbortController()
const initialClientPrerenderController = new AbortController()
const initialClientReactController = new AbortController()
const initialClientRenderController = new AbortController()
const initialClientPrerenderStore: PrerenderStore = {
type: 'prerender-client',
phase: 'render',
......@@ -2492,7 +2517,7 @@ async function spawnDynamicValidationInDev(
nonce={nonce}
/>,
{
signal: initialClientRenderController.signal,
signal: initialClientReactController.signal,
onError: (err) => {
const digest = getDigestForWellKnownError(err)
......@@ -2506,7 +2531,7 @@ async function spawnDynamicValidationInDev(
return undefined
}
if (initialClientRenderController.signal.aborted) {
if (initialClientReactController.signal.aborted) {
// These are expected errors that might error the prerender. we ignore them.
} else if (
process.env.NEXT_DEBUG_BUILD ||
......@@ -2522,9 +2547,20 @@ async function spawnDynamicValidationInDev(
}
)
// The listener to abort our own render controller must be added after React
// has added its listener, to ensure that pending I/O is not
// aborted/rejected too early.
initialClientReactController.signal.addEventListener(
'abort',
() => {
initialClientRenderController.abort()
},
{ once: true }
)
pendingInitialClientResult.catch((err) => {
if (
initialServerRenderController.signal.aborted ||
initialClientReactController.signal.aborted ||
isPrerenderInterruptedError(err)
) {
// These are expected errors that might error the prerender. we ignore them.
......@@ -2542,10 +2578,12 @@ async function spawnDynamicValidationInDev(
// Promises passed to client were already awaited above (assuming that they came from cached functions)
trackPendingModules(cacheSignal)
await cacheSignal.cacheReady()
initialClientRenderController.abort()
initialClientReactController.abort()
}
const finalServerController = new AbortController()
const finalServerReactController = new AbortController()
const finalServerRenderController = new AbortController()
const serverDynamicTracking = createDynamicTrackingState(
false // isDebugDynamicAccesses
)
......@@ -2555,8 +2593,8 @@ async function spawnDynamicValidationInDev(
phase: 'render',
rootParams,
implicitTags,
renderSignal: finalServerController.signal,
controller: finalServerController,
renderSignal: finalServerRenderController.signal,
controller: finalServerReactController,
// All caches we could read must already be filled so no tracking is necessary
cacheSignal: null,
dynamicTracking: serverDynamicTracking,
......@@ -2582,7 +2620,7 @@ async function spawnDynamicValidationInDev(
const reactServerResult = await createReactServerPrerenderResult(
prerenderAndAbortInSequentialTasks(
async () => {
const prerenderResult = await workUnitAsyncStorage.run(
const pendingPrerenderResult = workUnitAsyncStorage.run(
// The store to scope
finalServerPrerenderStore,
// The function to run
......@@ -2594,7 +2632,7 @@ async function spawnDynamicValidationInDev(
filterStackFrame,
onError: (err: unknown) => {
if (
finalServerController.signal.aborted &&
finalServerReactController.signal.aborted &&
isPrerenderInterruptedError(err)
) {
return err.digest
......@@ -2608,13 +2646,25 @@ async function spawnDynamicValidationInDev(
return getDigestForWellKnownError(err)
},
signal: finalServerController.signal,
signal: finalServerReactController.signal,
}
)
return prerenderResult
// The listener to abort our own render controller must be added after
// React has added its listener, to ensure that pending I/O is not
// aborted/rejected too early.
finalServerReactController.signal.addEventListener(
'abort',
() => {
finalServerRenderController.abort()
},
{ once: true }
)
return pendingPrerenderResult
},
() => {
finalServerController.abort()
finalServerReactController.abort()
}
)
)
......@@ -2622,14 +2672,16 @@ async function spawnDynamicValidationInDev(
const clientDynamicTracking = createDynamicTrackingState(
false //isDebugDynamicAccesses
)
const finalClientController = new AbortController()
const finalClientReactController = new AbortController()
const finalClientRenderController = new AbortController()
const finalClientPrerenderStore: PrerenderStore = {
type: 'prerender-client',
phase: 'render',
rootParams,
implicitTags,
renderSignal: finalClientController.signal,
controller: finalClientController,
renderSignal: finalClientRenderController.signal,
controller: finalClientReactController,
// No APIs require a cacheSignal through the workUnitStore during the HTML prerender
cacheSignal: null,
dynamicTracking: clientDynamicTracking,
......@@ -2652,8 +2704,8 @@ async function spawnDynamicValidationInDev(
).prerender
let { prelude: unprocessedPrelude } =
await prerenderAndAbortInSequentialTasks(
() =>
workUnitAsyncStorage.run(
() => {
const pendingFinalClientResult = workUnitAsyncStorage.run(
finalClientPrerenderStore,
prerender,
<App
......@@ -2665,11 +2717,11 @@ async function spawnDynamicValidationInDev(
nonce={nonce}
/>,
{
signal: finalClientController.signal,
signal: finalClientReactController.signal,
onError: (err: unknown, errorInfo: ErrorInfo) => {
if (
isPrerenderInterruptedError(err) ||
finalClientController.signal.aborted
finalClientReactController.signal.aborted
) {
const componentStack = errorInfo.componentStack
if (typeof componentStack === 'string') {
......@@ -2694,9 +2746,23 @@ async function spawnDynamicValidationInDev(
// We don't need bootstrap scripts in this prerender
// bootstrapScripts: [bootstrapScript],
}
),
)
// The listener to abort our own render controller must be added after
// React has added its listener, to ensure that pending I/O is not
// aborted/rejected too early.
finalClientReactController.signal.addEventListener(
'abort',
() => {
finalClientRenderController.abort()
},
{ once: true }
)
return pendingFinalClientResult
},
() => {
finalClientController.abort()
finalClientReactController.abort()
}
)
......@@ -2933,15 +2999,27 @@ async function prerenderToStream(
* and the reactServerIsDynamic value to determine how to treat the resulting render
*/
// Prerender controller represents the lifetime of the prerender.
// It will be aborted when a Task is complete or a synchronously aborting
// API is called. Notably during cache-filling renders this does not actually
// terminate the render itself which will continue until all caches are filled
// The prerender controller represents the lifetime of the prerender. It
// will be aborted when a task is complete or a synchronously aborting API
// is called. Notably, during prospective prerenders, this does not
// actually terminate the prerender itself, which will continue until all
// caches are filled.
const initialServerPrerenderController = new AbortController()
// This controller represents the lifetime of the React render call. Notably
// during the cache-filling render it is different from the prerender controller
// because we don't want to end the react render until all caches are filled.
// This controller is used to abort the React prerender.
const initialServerReactController = new AbortController()
// This controller represents the lifetime of the React prerender. Its
// signal can be used for any I/O operation to abort the I/O and/or to
// reject, when prerendering aborts. This includes our own hanging
// promises for accessing request data, and for fetch calls. It might be
// replaced in the future by React.cacheSignal(). It's aborted after the
// React controller, so that no pending I/O can register abort listeners
// that are called before React's abort listener is called. This ensures
// that pending I/O is not rejected too early when aborting the prerender.
// Notably, during the prospective prerender, it is different from the
// prerender controller because we don't want to end the React prerender
// until all caches are filled.
const initialServerRenderController = new AbortController()
// The cacheSignal helps us track whether caches are still filling or we are ready
......@@ -3035,16 +3113,26 @@ async function prerenderToStream(
// We don't want to stop rendering until the cacheSignal is complete so we pass
// a different signal to this render call than is used by dynamic APIs to signify
// transitioning out of the prerender environment
signal: initialServerRenderController.signal,
signal: initialServerReactController.signal,
}
)
// The listener to abort our own render controller must be added after
// React has added its listener, to ensure that pending I/O is not
// aborted/rejected too early.
initialServerReactController.signal.addEventListener(
'abort',
() => {
initialServerRenderController.abort()
},
{ once: true }
)
// Wait for all caches to be finished filling and for async imports to resolve
trackPendingModules(cacheSignal)
await cacheSignal.cacheReady()
initialServerRenderController.abort()
initialServerPrerenderController.abort()
initialServerReactController.abort()
// We don't need to continue the prerender process if we already
// detected invalid dynamic usage in the initial prerender phase.
......@@ -3060,7 +3148,7 @@ async function prerenderToStream(
)
} catch (err) {
if (
initialServerRenderController.signal.aborted ||
initialServerReactController.signal.aborted ||
initialServerPrerenderController.signal.aborted
) {
// These are expected errors that might error the prerender. we ignore them.
......@@ -3075,8 +3163,10 @@ async function prerenderToStream(
}
if (initialServerResult) {
const initialClientRenderController = new AbortController()
const initialClientPrerenderController = new AbortController()
const initialClientReactController = new AbortController()
const initialClientRenderController = new AbortController()
const initialClientPrerenderStore: PrerenderStore = {
type: 'prerender-client',
phase: 'render',
......@@ -3114,7 +3204,7 @@ async function prerenderToStream(
nonce={nonce}
/>,
{
signal: initialClientRenderController.signal,
signal: initialClientReactController.signal,
onError: (err) => {
const digest = getDigestForWellKnownError(err)
......@@ -3128,7 +3218,7 @@ async function prerenderToStream(
return undefined
}
if (initialClientRenderController.signal.aborted) {
if (initialClientReactController.signal.aborted) {
// These are expected errors that might error the prerender. we ignore them.
} else if (
process.env.NEXT_DEBUG_BUILD ||
......@@ -3143,9 +3233,20 @@ async function prerenderToStream(
}
)
// The listener to abort our own render controller must be added after
// React has added its listener, to ensure that pending I/O is not
// aborted/rejected too early.
initialClientReactController.signal.addEventListener(
'abort',
() => {
initialClientRenderController.abort()
},
{ once: true }
)
pendingInitialClientResult.catch((err) => {
if (
initialServerRenderController.signal.aborted ||
initialClientReactController.signal.aborted ||
isPrerenderInterruptedError(err)
) {
// These are expected errors that might error the prerender. we ignore them.
......@@ -3163,11 +3264,13 @@ async function prerenderToStream(
// Promises passed to client were already awaited above (assuming that they came from cached functions)
trackPendingModules(cacheSignal)
await cacheSignal.cacheReady()
initialClientRenderController.abort()
initialClientReactController.abort()
}
let serverIsDynamic = false
const finalServerController = new AbortController()
const finalServerReactController = new AbortController()
const finalServerRenderController = new AbortController()
const serverDynamicTracking = createDynamicTrackingState(
isDebugDynamicAccesses
)
......@@ -3177,8 +3280,8 @@ async function prerenderToStream(
phase: 'render',
rootParams,
implicitTags,
renderSignal: finalServerController.signal,
controller: finalServerController,
renderSignal: finalServerRenderController.signal,
controller: finalServerReactController,
// All caches we could read must already be filled so no tracking is necessary
cacheSignal: null,
dynamicTracking: serverDynamicTracking,
......@@ -3205,7 +3308,7 @@ async function prerenderToStream(
await createReactServerPrerenderResult(
prerenderAndAbortInSequentialTasks(
async () => {
const prerenderResult = await workUnitAsyncStorage.run(
const pendingPrerenderResult = workUnitAsyncStorage.run(
// The store to scope
finalServerPrerenderStore,
// The function to run
......@@ -3218,14 +3321,28 @@ async function prerenderToStream(
onError: (err: unknown) => {
return serverComponentsErrorHandler(err)
},
signal: finalServerController.signal,
signal: finalServerReactController.signal,
}
)
// The listener to abort our own render controller must be added
// after React has added its listener, to ensure that pending I/O
// is not aborted/rejected too early.
finalServerReactController.signal.addEventListener(
'abort',
() => {
finalServerRenderController.abort()
},
{ once: true }
)
const prerenderResult = await pendingPrerenderResult
prerenderIsPending = false
return prerenderResult
},
() => {
if (finalServerController.signal.aborted) {
if (finalServerReactController.signal.aborted) {
// If the server controller is already aborted we must have called something
// that required aborting the prerender synchronously such as with new Date()
serverIsDynamic = true
......@@ -3237,7 +3354,8 @@ async function prerenderToStream(
// there is something unfinished.
serverIsDynamic = true
}
finalServerController.abort()
finalServerReactController.abort()
}
)
))
......@@ -3245,14 +3363,17 @@ async function prerenderToStream(
const clientDynamicTracking = createDynamicTrackingState(
isDebugDynamicAccesses
)
const finalClientController = new AbortController()
const finalClientReactController = new AbortController()
const finalClientRenderController = new AbortController()
const finalClientPrerenderStore: PrerenderStore = {
type: 'prerender-client',
phase: 'render',
rootParams,
implicitTags,
renderSignal: finalClientController.signal,
controller: finalClientController,
renderSignal: finalClientRenderController.signal,
controller: finalClientReactController,
// No APIs require a cacheSignal through the workUnitStore during the HTML prerender
cacheSignal: null,
dynamicTracking: clientDynamicTracking,
......@@ -3274,8 +3395,8 @@ async function prerenderToStream(
).prerender
let { prelude: unprocessedPrelude, postponed } =
await prerenderAndAbortInSequentialTasks(
() =>
workUnitAsyncStorage.run(
() => {
const pendingFinalClientResult = workUnitAsyncStorage.run(
finalClientPrerenderStore,
prerender,
<App
......@@ -3287,11 +3408,11 @@ async function prerenderToStream(
nonce={nonce}
/>,
{
signal: finalClientController.signal,
signal: finalClientReactController.signal,
onError: (err: unknown, errorInfo: ErrorInfo) => {
if (
isPrerenderInterruptedError(err) ||
finalClientController.signal.aborted
finalClientReactController.signal.aborted
) {
const componentStack: string | undefined = (
errorInfo as any
......@@ -3317,9 +3438,23 @@ async function prerenderToStream(
maxHeadersLength: reactMaxHeadersLength,
bootstrapScripts: [bootstrapScript],
}
),
)
// The listener to abort our own render controller must be added
// after React has added its listener, to ensure that pending I/O is
// not aborted/rejected too early.
finalClientReactController.signal.addEventListener(
'abort',
() => {
finalClientRenderController.abort()
},
{ once: true }
)
return pendingFinalClientResult
},
() => {
finalClientController.abort()
finalClientReactController.abort()
}
)
......
......@@ -92,20 +92,32 @@ interface PrerenderStoreModernServer extends PrerenderStoreModernCommon {
interface PrerenderStoreModernCommon extends CommonWorkUnitStore {
/**
* This signal is aborted when the React render is complete. (i.e. it is the same signal passed to react)
* The render signal is aborted after React's `prerender` function is aborted
* (using a separate signal), which happens in two cases:
*
* 1. When all caches are filled during the prospective prerender.
* 2. When the final prerender is aborted immediately after the prerender was
* started.
*
* It can be used to reject any pending I/O, including hanging promises. This
* allows React to properly track the async I/O in dev mode, which yields
* better owner stacks for dynamic validation errors.
*/
readonly renderSignal: AbortSignal
/**
* This is the AbortController which represents the boundary between Prerender and dynamic. In some renders it is
* the same as the controller for the renderSignal but in others it is a separate controller. It should be aborted
* whenever the we are no longer in the prerender phase of rendering. Typically this is after one task or when you call
* a sync API which requires the prerender to end immediately
* This is the AbortController which represents the boundary between Prerender
* and dynamic. In some renders it is the same as the controller for React,
* but in others it is a separate controller. It should be aborted whenever we
* are no longer in the prerender phase of rendering. Typically this is after
* one task, or when you call a sync API which requires the prerender to end
* immediately.
*/
readonly controller: AbortController
/**
* when not null this signal is used to track cache reads during prerendering and
* to await all cache reads completing before aborting the prerender.
* When not null, this signal is used to track cache reads during prerendering
* and to await all cache reads completing, before aborting the prerender.
*/
readonly cacheSignal: null | CacheSignal
......
......@@ -559,7 +559,7 @@ export function createPatchedFetcher(
cacheSignal = null
}
return await makeHangingPromise<Response>(
return makeHangingPromise<Response>(
workUnitStore.renderSignal,
'fetch()'
)
......@@ -669,7 +669,7 @@ export function createPatchedFetcher(
cacheSignal.endRead()
cacheSignal = null
}
return await makeHangingPromise<Response>(
return makeHangingPromise<Response>(
workUnitStore.renderSignal,
'fetch()'
)
......@@ -1010,7 +1010,7 @@ export function createPatchedFetcher(
cacheSignal.endRead()
cacheSignal = null
}
return await makeHangingPromise<Response>(
return makeHangingPromise<Response>(
workUnitStore.renderSignal,
'fetch()'
)
......@@ -1044,7 +1044,7 @@ export function createPatchedFetcher(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
return await makeHangingPromise<Response>(
return makeHangingPromise<Response>(
workUnitStore.renderSignal,
'fetch()'
)
......
......@@ -821,7 +821,7 @@ export function cache(
)
if (dynamicAccessAbortController.signal.aborted) {
return await makeHangingPromise(
return makeHangingPromise(
workUnitStore.renderSignal,
dynamicAccessAbortController.signal.reason.message
)
......@@ -886,7 +886,7 @@ export function cache(
if (cacheSignal) {
cacheSignal.endRead()
}
return await makeHangingPromise(
return makeHangingPromise(
workUnitStore.renderSignal,
'dynamic "use cache"'
)
......@@ -935,7 +935,7 @@ export function cache(
// transformed with an async function, before being passed into
// the "use cache" function, which escapes the instrumentation.
if (workUnitStore.allowEmptyStaticShell) {
return await makeHangingPromise(
return makeHangingPromise(
workUnitStore.renderSignal,
'dynamic "use cache"'
)
......@@ -1030,7 +1030,7 @@ export function cache(
if (cacheSignal) {
cacheSignal.endRead()
}
return await makeHangingPromise(
return makeHangingPromise(
workUnitStore.renderSignal,
'dynamic "use cache"'
)
......@@ -1087,7 +1087,7 @@ export function cache(
)
if (result.type === 'prerender-dynamic') {
return await result.hangingPromise
return result.hangingPromise
}
const { stream: newStream, pendingCacheEntry } = result
......
......@@ -1758,20 +1758,20 @@ describe('Cache Components Errors', () => {
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "Route "/sync-attribution/unguarded-async-guarded-clientsync": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense",
"environmentLabel": "Server",
"label": "Console Error",
"source": "app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (33:16) @ RequestData
> 33 | async function RequestData() {
| ^",
"stack": [
"RequestData app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (33:16)",
"Page app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (27:9)",
"LogSafely <anonymous>",
],
}
`)
{
"description": "Route "/sync-attribution/unguarded-async-guarded-clientsync": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense",
"environmentLabel": "Server",
"label": "Console Error",
"source": "app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (34:18) @ RequestData
> 34 | ;(await cookies()).get('foo')
| ^",
"stack": [
"RequestData app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (34:18)",
"Page app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (27:9)",
"LogSafely <anonymous>",
],
}
`)
}
})
} else {
......
#!/usr/bin/env bash
# Run `test/e2e/app-dir/cache-components-errors/update-snapshots.sh` from the root of
# the monorepo to update the snapshots of the cache components errors test suite.
# Run `test/e2e/app-dir/cache-components-errors/update-snapshots.sh` from the
# root of the monorepo to update the snapshots of the cache components errors
# test suite.
set -xeuo pipefail
SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}`
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]-$0}")
TESTS=("$SCRIPT_DIR/cache-components-errors.test.ts")
DEV=false
START=false
# Parse CLI flags
for arg in "$@"; do
case "$arg" in
--dev) DEV=true ;;
--start) START=true ;;
*) echo "Unknown option: $arg"; exit 1 ;;
esac
done
# If no flags are provided, update all snapshots.
if [ "$DEV" = false ] && [ "$START" = false ]; then
DEV=true
START=true
fi
# Update `next dev` snapshots for both Turbopack and Webpack.
pnpm test-dev "${TESTS[@]}" --projects jest.config.* -u
if [ "$DEV" = true ]; then
pnpm test-dev "${TESTS[@]}" --projects jest.config.* -u
fi
# The `next start` snapshots can't be created for both prerender modes at the
# same time because of an issue in the typescript plugin for prettier.
NEXT_TEST_DEBUG_PRERENDER=false pnpm test-start "${TESTS[@]}" --projects jest.config.* -u
NEXT_TEST_DEBUG_PRERENDER=true pnpm test-start "${TESTS[@]}" --projects jest.config.* -u
if [ "$START" = true ]; then
NEXT_TEST_DEBUG_PRERENDER=false pnpm test-start "${TESTS[@]}" --projects jest.config.* -u
NEXT_TEST_DEBUG_PRERENDER=true pnpm test-start "${TESTS[@]}" --projects jest.config.* -u
fi
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