next.js
2e327560 - Include server latency in debug info (#84580)

Commit
196 days ago
Include server latency in debug info (#84580) The debug info of the promise created by the Flight client represents the latency between when the navigation starts and when it's passed to React. Most importantly, it should include the time it takes for the client to start receiving data from the server. Before this PR, the timing was too late because we did not call into the Flight client until after we started receiving data. To fix this, we switch from using `createFromReadableStream` to `createFromFetch`. This allows us to call into the Flight client immediately without waiting for the `fetch` promise to resolve. The `_debugInfo` field contains the profiling information. Promises that are created by Flight already have this info added by React; for any derived promise created by the router, we need to transfer the Flight debug info onto the derived promise. Concretely, we create a derived promise for each route segment contained in a response. Any nested promises contained with that segment are passed directly from Flight to React and don't require special processing.
Author
Parents
Loading