next.js
a0e5996f - [Cache Components] Allow sync IO inside console methods (#83843)

Commit
132 days ago
[Cache Components] Allow sync IO inside console methods (#83843) console methods may be patched to do things like add a timestamp to the log row. While we can't determine the meaning of reading the current time in arbitrary contexts we can know with reasonable certainty that any sync IO inside a console method is not being used in the logical output of the program. To account for this we can make a special affordance for sync IO inside of these methods that allows them to run without interrupting the prerender early. To do this we patch these properties on the console global and set up a wrapper in the setter. This wrapper will make any assigned function into another function that exits the `workUnitAsyncStorage` scope before executing the wrapped function. This will allow `new Date()` and other sync IO APIs to be called in the internal implementation of these methods without triggering an error while prerendering. Fixes NAR-403
Author
Parents
Loading