Skip to content

Commit 8c5e017

Browse files
committed
Emit error chunk if Lazy is rejected
1 parent bc896c6 commit 8c5e017

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,11 +4716,18 @@ function renderDebugModel(
47164716
case -1 /* Uninitialized */:
47174717
case 0 /* Pending */:
47184718
break;
4719-
case 1 /* Resolved */:
4720-
case 2 /* Rejected */: {
4719+
case 1 /* Resolved */: {
47214720
const id = outlineDebugModel(request, counter, payload._result);
47224721
return serializeLazyID(id);
47234722
}
4723+
case 2 /* Rejected */: {
4724+
// We don't log these errors since they didn't actually throw into
4725+
// Flight.
4726+
const digest = '';
4727+
const id = request.nextChunkId++;
4728+
emitErrorChunk(request, id, digest, payload._result, true, null);
4729+
return serializeLazyID(id);
4730+
}
47244731
}
47254732

47264733
// React Flight
@@ -4733,14 +4740,18 @@ function renderDebugModel(
47334740
break;
47344741
case 'resolved_module':
47354742
// The value is client reference metadata from the Flight client.
4736-
// It's likely for SSR, so we chose not to emit it.
4743+
// It's likely for SSR, so we choose not to emit it.
47374744
break;
47384745
case 'fulfilled': {
47394746
const id = outlineDebugModel(request, counter, payload.value);
47404747
return serializeLazyID(id);
47414748
}
47424749
case 'rejected': {
4743-
const id = outlineDebugModel(request, counter, payload.reason);
4750+
// We don't log these errors since they didn't actually throw into
4751+
// Flight.
4752+
const digest = '';
4753+
const id = request.nextChunkId++;
4754+
emitErrorChunk(request, id, digest, payload.reason, true, null);
47444755
return serializeLazyID(id);
47454756
}
47464757
}

0 commit comments

Comments
 (0)