prevent cookies from being set in the wrong phase (#71094)
makes the object returned by `cookies() check if the phase we're currently in allows mutations. - `(await cookies()).set(...)` will no longer be allowed in a render that follows an action (previously, this'd work, because `actionStore.isAction` is still true during the render!) - `unstable_after(async () => (await cookies()).set(...))` will error - `const store = await cookies(); unstable_after(() => store.set(...))` will now also error this affects a couple places that mutate cookies in a way that we don't let userspace code do, like draftmode. to support this, i've added `workUnitStore.userspaceMutableCookies` and made *only that one* check for invalid accesses. that's the one we return from `cookies()` in a mutable context. the rest of the codebase can continue using `workUnitStore.mutableCookies` without worrying about phase checks.
Showing
Please
register
or
sign in
to comment