-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
add phase tracking to workUnitStore #71030
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,13 @@ import type { DynamicTrackingState } from './dynamic-rendering' | |
import { workUnitAsyncStorage } from './work-unit-async-storage-instance' with { 'turbopack-transition': 'next-shared' } | ||
import type { ServerComponentsHmrCache } from '../response-cache' | ||
|
||
type WorkUnitPhase = 'action' | 'render' | 'after' | ||
|
||
type PhasePartial = { | ||
/** NOTE: Will be mutated as phases change */ | ||
phase: WorkUnitPhase | ||
} | ||
|
||
export type RequestStore = { | ||
type: 'request' | ||
|
||
|
@@ -41,7 +48,7 @@ export type RequestStore = { | |
|
||
// DEV-only | ||
usedDynamic?: boolean | ||
} | ||
} & PhasePartial | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. personally not a fan of use of partials for unioning. In this case it makes it possible for prerender stores to be constructed with or turned into action phase which should be impossible. It also makes it harder to see the complete type details in the IDE There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In reviewing further I see why prerender store needs action as a valid phase. Kind of unfortunate since this is only true in the route handler case. But still I think I'd just recommend we repeat the valid phases per store type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah originally i only had |
||
|
||
/** | ||
* The Prerender store is for tracking information related to prerenders. | ||
|
@@ -81,7 +88,7 @@ export type PrerenderStoreModern = { | |
// Collected revalidate times and tags for this document during the prerender. | ||
revalidate: number // in seconds. 0 means dynamic. INFINITE_CACHE and higher means never revalidate. | ||
tags: null | string[] | ||
} | ||
} & PhasePartial | ||
|
||
export type PrerenderStorePPR = { | ||
type: 'prerender-ppr' | ||
|
@@ -90,15 +97,15 @@ export type PrerenderStorePPR = { | |
// Collected revalidate times and tags for this document during the prerender. | ||
revalidate: number // in seconds. 0 means dynamic. INFINITE_CACHE and higher means never revalidate. | ||
tags: null | string[] | ||
} | ||
} & PhasePartial | ||
|
||
export type PrerenderStoreLegacy = { | ||
type: 'prerender-legacy' | ||
readonly implicitTags: string[] | ||
// Collected revalidate times and tags for this document during the prerender. | ||
revalidate: number // in seconds. 0 means dynamic. INFINITE_CACHE and higher means never revalidate. | ||
tags: null | string[] | ||
} | ||
} & PhasePartial | ||
|
||
export type PrerenderStore = | ||
| PrerenderStoreLegacy | ||
|
@@ -112,11 +119,11 @@ export type UseCacheStore = { | |
revalidate: number // implicit revalidate time from inner caches / fetches | ||
explicitRevalidate: undefined | number // explicit revalidate time from cacheLife() calls | ||
tags: null | string[] | ||
} | ||
} & PhasePartial | ||
|
||
export type UnstableCacheStore = { | ||
type: 'unstable-cache' | ||
} | ||
} & PhasePartial | ||
|
||
/** | ||
* The Cache store is for tracking information inside a "use cache" or unstable_cache context. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not 100% sure if this is the way to do it -- i can see an argument that this should be set independently, before this function runs, and just be an invariant here. but this works (in particular for the case of going
action
->render
) and it's hard to do it differently forafter
(which is currently kinda in control of when its stuff runs without exposing much to the outside world), so this is the convention i've settled on