Background
Backport of facebook/react#35776 — ~75% speedup in RSC chunk deserialization.
The react-server-dom-webpack package currently uses JSON.parse(json, reviver) to deserialize RSC payloads. The reviver callback is a major bottleneck: V8's JSON.parse is implemented in C++, and invoking a JS reviver callback for every key-value pair incurs ~4x overhead even with a no-op reviver.
Proposed change
Replace JSON.parse(json, reviver) with a two-step approach:
JSON.parse(json) — runs entirely in V8's C++ engine, no callbacks
reviveModel() — recursive pure-JS walk that applies RSC transformations
This needs to be applied across all runtime environments (browser, edge, Node.js).
Benchmark results (from upstream PR)
| Payload |
Speedup |
| Small (142B) |
+72% |
| Medium (914B) |
+73% |
| Large (16.7KB) |
+75% |
| XL (25.7KB) |
+76% |
| Table (1000 rows, 110KB) |
+78% |
Implementation approach
Rebuild react-server-dom-webpack from React fork rsc-patches/v19.0.3 with the optimization applied (fork PR).
Acceptance criteria
Background
Backport of facebook/react#35776 — ~75% speedup in RSC chunk deserialization.
The
react-server-dom-webpackpackage currently usesJSON.parse(json, reviver)to deserialize RSC payloads. The reviver callback is a major bottleneck: V8'sJSON.parseis implemented in C++, and invoking a JS reviver callback for every key-value pair incurs ~4x overhead even with a no-op reviver.Proposed change
Replace
JSON.parse(json, reviver)with a two-step approach:JSON.parse(json)— runs entirely in V8's C++ engine, no callbacksreviveModel()— recursive pure-JS walk that applies RSC transformationsThis needs to be applied across all runtime environments (browser, edge, Node.js).
Benchmark results (from upstream PR)
Implementation approach
Rebuild
react-server-dom-webpackfrom React forkrsc-patches/v19.0.3with the optimization applied (fork PR).Acceptance criteria