next.js
fbc9a2b9 - [Cache Components] Atomic setTimeouts (#86093)

Commit
40 days ago
[Cache Components] Atomic setTimeouts (#86093) This PR exploits some Node internals to make sure that, if we schedule some timeouts back to back to perform staged rendering, they'll actually run in the same iteration of the event loop. If we cannot patch the timeouts correctly (due to runtime differences in e.g. Bun, or changes in future node versions), we'll warn that Cache Components may not function correctly, and run the timers normally. timer/immediate interleaving is rare in practice, and we'll usually be fine even without this patch, so it's better to warn and try to carry on rather than to error out. (h/t to @sokra for finding this trick)
Author
Parents
Loading