Skip to content

Commit

Permalink
[Flight] Ship DEV-only enableServerComponentLogs flag in Stable/Canary (
Browse files Browse the repository at this point in the history
#30847)

To recap. This only affects DEV and RSC. It patches console on the
server in DEV (similar to how React DevTools already does and what we
did for the double logging). Then replays those logs with a `[Server]`
badge on the client so you don't need a server terminal open.

This has been on for over 6 months now in our experimental channel and
we've had a lot of coverage in Next.js due to various experimental flags
like taint and ppr.

It's non-invasive in that even if something throws we just serialize
that as an unknown value.

The main feedback we've gotten was:

- The serialization depth wasn't deep enough which I addressed in #30294
and haven't really had any issues since. This could still be an issue or
the inverse that you serialize too many logs that are also too deep.
This is not so much an issue with intentional logging and things like
accidental errors don't typically have unbounded arguments (e.g. React
errors are always string arguments). The ideal would be some way to
retain objects and then load them on-demand but that needs more
plumbing. Which can be later.
- The other was that double logging on the server is annoying if the
same terminal does both the RSC render and SSR render which was
addressed in #30207. It is now off by default in node/edge-builds of the
client, on by default in browser builds. With the `replayConsole` option
to either opt-in or out.

We've reached a good spot now I think.

These are better with `enableOwnerStacks` but that's a separate track
and not needed.

The only thing to document here, other than maybe that we're doing it,
is the `replayConsole` option but that's part of the RSC renderers that
themselves are not documented so nowhere to document it.
  • Loading branch information
sebmarkbage authored Aug 30, 2024
1 parent e56f4ae commit 4f60494
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const alwaysThrottleRetries = true;

export const passChildrenWhenCloningPersistedNodes = false;

export const enableServerComponentLogs = __EXPERIMENTAL__;
export const enableServerComponentLogs = true;

/**
* Enables a new Fiber flag used in persisted mode to reduce the number
Expand Down

0 comments on commit 4f60494

Please sign in to comment.