add phase tracking to workUnitStore (#71030)
Introduces a mutable `phase` field on `workUnitStore` to mark the points where we switch to different phases of handling a request. examples: - handling a Server action has three phases: - `action` - when running the action's body (until it returns) - `render` - when rendering any returned JSX (and possibly the page, if revalidated) - `after` - when `unstable_after` callbacks run - Pages have two phases: `render` and `after`. - Route handlers and middleware have two phases: `action` and `after`. We're re-using the `action` name because the phase is really about controlling whether APIs like `cookies().set` are callable or not, and unlike `render` both of those allow mutations. This PR adds the basic tracking mechanism, I've split code that actually uses these phases to control behavior out into - https://github.com/vercel/next.js/pull/71094 - https://github.com/vercel/next.js/pull/71093 because some details of those might require more bikeshedding/tweaks
Showing
Please
register
or
sign in
to comment