react-server-dom-webpack 19.0.0-rc-99da76f23a-20240606 → 19.0.0-rc-827cbea417-20240606

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,6 +94,16 @@ function printWarning(level, format, args, currentStack) {
94
94
  }
95
95
  }
96
96
 
97
+ function handleErrorInNextTick(error) {
98
+ setTimeout(function () {
99
+ throw error;
100
+ });
101
+ }
102
+
103
+ var LocalPromise = Promise;
104
+ var scheduleMicrotask = typeof queueMicrotask === 'function' ? queueMicrotask : function (callback) {
105
+ LocalPromise.resolve(null).then(callback).catch(handleErrorInNextTick);
106
+ };
97
107
  function scheduleWork(callback) {
98
108
  setTimeout(callback, 0);
99
109
  }
@@ -1579,6 +1589,8 @@ var PENDING$1 = 0;
1579
1589
  var COMPLETED = 1;
1580
1590
  var ABORTED = 3;
1581
1591
  var ERRORED$1 = 4;
1592
+ var RENDERING = 5;
1593
+ var AbortSigil = {};
1582
1594
 
1583
1595
  function defaultErrorHandler(error) {
1584
1596
  console['error'](error); // Don't transform to our wrapper
@@ -1588,8 +1600,9 @@ function defaultPostponeHandler(reason) {// Noop
1588
1600
  }
1589
1601
 
1590
1602
  var OPEN = 0;
1591
- var CLOSING = 1;
1592
- var CLOSED = 2;
1603
+ var ABORTING = 1;
1604
+ var CLOSING = 2;
1605
+ var CLOSED = 3;
1593
1606
  function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName, temporaryReferences) {
1594
1607
  if (ReactSharedInternals.A !== null && ReactSharedInternals.A !== DefaultAsyncDispatcher) {
1595
1608
  throw new Error('Currently React only supports one RSC renderer at a time.');
@@ -1687,6 +1700,16 @@ function serializeThenable(request, task, thenable) {
1687
1700
 
1688
1701
  default:
1689
1702
  {
1703
+ if (request.status === ABORTING) {
1704
+ // We can no longer accept any resolved values
1705
+ newTask.status = ABORTED;
1706
+ var errorId = request.fatalError;
1707
+ var model = stringify(serializeByValueID(errorId));
1708
+ emitModelChunk(request, newTask.id, model);
1709
+ request.abortableTasks.delete(newTask);
1710
+ return newTask.id;
1711
+ }
1712
+
1690
1713
  if (typeof thenable.status === 'string') {
1691
1714
  // Only instrument the thenable if the status if not defined. If
1692
1715
  // it's defined, but an unknown value, assume it's been instrumented by
@@ -2063,6 +2086,13 @@ validated) // DEV-only
2063
2086
  result = callComponentInDEV(Component, props, componentDebugInfo);
2064
2087
  }
2065
2088
 
2089
+ if (request.status === ABORTING) {
2090
+ // If we aborted during rendering we should interrupt the render but
2091
+ // we don't need to provide an error because the renderer will encode
2092
+ // the abort error as the reason.
2093
+ throw AbortSigil;
2094
+ }
2095
+
2066
2096
  if (typeof result === 'object' && result !== null && !isClientReference(result)) {
2067
2097
  if (typeof result.then === 'function') {
2068
2098
  // When the return value is in children position we can resolve it immediately,
@@ -2404,6 +2434,13 @@ validated) // DEV only
2404
2434
  wrappedType = callLazyInitInDEV(type);
2405
2435
  }
2406
2436
 
2437
+ if (request.status === ABORTING) {
2438
+ // lazy initializers are user code and could abort during render
2439
+ // we don't wan to return any value resolved from the lazy initializer
2440
+ // if it aborts so we interrupt rendering here
2441
+ throw AbortSigil;
2442
+ }
2443
+
2407
2444
  return renderElement(request, task, wrappedType, key, ref, props, owner);
2408
2445
  }
2409
2446
 
@@ -2428,7 +2465,7 @@ function pingTask(request, task) {
2428
2465
 
2429
2466
  if (pingedTasks.length === 1) {
2430
2467
  request.flushScheduled = request.destination !== null;
2431
- scheduleWork(function () {
2468
+ scheduleMicrotask(function () {
2432
2469
  return performWork(request);
2433
2470
  });
2434
2471
  }
@@ -2726,21 +2763,32 @@ function renderModel(request, task, parent, key, value) {
2726
2763
  try {
2727
2764
  return renderModelDestructive(request, task, parent, key, value);
2728
2765
  } catch (thrownValue) {
2766
+ // If the suspended/errored value was an element or lazy it can be reduced
2767
+ // to a lazy reference, so that it doesn't error the parent.
2768
+ var model = task.model;
2769
+ var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
2729
2770
  var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
2730
2771
  // reasons, the rest of the Suspense implementation expects the thrown
2731
2772
  // value to be a thenable, because before `use` existed that was the
2732
2773
  // (unstable) API for suspending. This implementation detail can change
2733
2774
  // later, once we deprecate the old API in favor of `use`.
2734
- getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
2735
- // to a lazy reference, so that it doesn't error the parent.
2736
-
2737
- var model = task.model;
2738
- var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
2775
+ getSuspendedThenable() : thrownValue;
2739
2776
 
2740
2777
  if (typeof x === 'object' && x !== null) {
2741
2778
  // $FlowFixMe[method-unbinding]
2742
2779
  if (typeof x.then === 'function') {
2743
- // Something suspended, we'll need to create a new task and resolve it later.
2780
+ if (request.status === ABORTING) {
2781
+ task.status = ABORTED;
2782
+ var errorId = request.fatalError;
2783
+
2784
+ if (wasReactNode) {
2785
+ return serializeLazyID(errorId);
2786
+ }
2787
+
2788
+ return serializeByValueID(errorId);
2789
+ } // Something suspended, we'll need to create a new task and resolve it later.
2790
+
2791
+
2744
2792
  var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
2745
2793
  var ping = newTask.ping;
2746
2794
  x.then(ping, ping);
@@ -2756,6 +2804,17 @@ function renderModel(request, task, parent, key, value) {
2756
2804
 
2757
2805
  return serializeByValueID(newTask.id);
2758
2806
  }
2807
+ }
2808
+
2809
+ if (thrownValue === AbortSigil) {
2810
+ task.status = ABORTED;
2811
+ var _errorId = request.fatalError;
2812
+
2813
+ if (wasReactNode) {
2814
+ return serializeLazyID(_errorId);
2815
+ }
2816
+
2817
+ return serializeByValueID(_errorId);
2759
2818
  } // Restore the context. We assume that this will be restored by the inner
2760
2819
  // functions in case nothing throws so we don't use "finally" here.
2761
2820
 
@@ -2768,10 +2827,12 @@ function renderModel(request, task, parent, key, value) {
2768
2827
  // We'll replace this element with a lazy reference that throws on the client
2769
2828
  // once it gets rendered.
2770
2829
  request.pendingChunks++;
2771
- var errorId = request.nextChunkId++;
2830
+
2831
+ var _errorId2 = request.nextChunkId++;
2832
+
2772
2833
  var digest = logRecoverableError(request, x);
2773
- emitErrorChunk(request, errorId, digest, x);
2774
- return serializeLazyID(errorId);
2834
+ emitErrorChunk(request, _errorId2, digest, x);
2835
+ return serializeLazyID(_errorId2);
2775
2836
  } // Something errored but it was not in a React Node. There's no need to serialize
2776
2837
  // it by value because it'll just error the whole parent row anyway so we can
2777
2838
  // just stop any siblings and error the whole parent row.
@@ -2875,6 +2936,13 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2875
2936
  resolvedModel = callLazyInitInDEV(lazy);
2876
2937
  }
2877
2938
 
2939
+ if (request.status === ABORTING) {
2940
+ // lazy initializers are user code and could abort during render
2941
+ // we don't wan to return any value resolved from the lazy initializer
2942
+ // if it aborts so we interrupt rendering here
2943
+ throw AbortSigil;
2944
+ }
2945
+
2878
2946
  {
2879
2947
  var _debugInfo = lazy._debugInfo;
2880
2948
 
@@ -3789,6 +3857,7 @@ function retryTask(request, task) {
3789
3857
  }
3790
3858
 
3791
3859
  var prevDebugID = debugID;
3860
+ task.status = RENDERING;
3792
3861
 
3793
3862
  try {
3794
3863
  // Track the root so we know that we have to emit this object even though it
@@ -3845,14 +3914,35 @@ function retryTask(request, task) {
3845
3914
  if (typeof x === 'object' && x !== null) {
3846
3915
  // $FlowFixMe[method-unbinding]
3847
3916
  if (typeof x.then === 'function') {
3848
- // Something suspended again, let's pick it back up later.
3917
+ if (request.status === ABORTING) {
3918
+ request.abortableTasks.delete(task);
3919
+ task.status = ABORTED;
3920
+ var errorId = request.fatalError;
3921
+ var model = stringify(serializeByValueID(errorId));
3922
+ emitModelChunk(request, task.id, model);
3923
+ return;
3924
+ } // Something suspended again, let's pick it back up later.
3925
+
3926
+
3927
+ task.status = PENDING$1;
3928
+ task.thenableState = getThenableStateAfterSuspending();
3849
3929
  var ping = task.ping;
3850
3930
  x.then(ping, ping);
3851
- task.thenableState = getThenableStateAfterSuspending();
3852
3931
  return;
3853
3932
  }
3854
3933
  }
3855
3934
 
3935
+ if (x === AbortSigil) {
3936
+ request.abortableTasks.delete(task);
3937
+ task.status = ABORTED;
3938
+ var _errorId3 = request.fatalError;
3939
+
3940
+ var _model = stringify(serializeByValueID(_errorId3));
3941
+
3942
+ emitModelChunk(request, task.id, _model);
3943
+ return;
3944
+ }
3945
+
3856
3946
  request.abortableTasks.delete(task);
3857
3947
  task.status = ERRORED$1;
3858
3948
  var digest = logRecoverableError(request, x);
@@ -3914,6 +4004,11 @@ function performWork(request) {
3914
4004
  }
3915
4005
 
3916
4006
  function abortTask(task, request, errorId) {
4007
+ if (task.status === RENDERING) {
4008
+ // This task will be aborted by the render
4009
+ return;
4010
+ }
4011
+
3917
4012
  task.status = ABORTED; // Instead of emitting an error per task.id, we emit a model that only
3918
4013
  // has a single value referencing the error.
3919
4014
 
@@ -4006,6 +4101,7 @@ function flushCompletedChunks(request, destination) {
4006
4101
 
4007
4102
  if (request.pendingChunks === 0) {
4008
4103
 
4104
+ request.status = CLOSED;
4009
4105
  close$1(destination);
4010
4106
  request.destination = null;
4011
4107
  }
@@ -4030,10 +4126,14 @@ function enqueueFlush(request) {
4030
4126
  request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
4031
4127
  // happen when we start flowing again
4032
4128
  request.destination !== null) {
4033
- var destination = request.destination;
4034
4129
  request.flushScheduled = true;
4035
4130
  scheduleWork(function () {
4036
- return flushCompletedChunks(request, destination);
4131
+ request.flushScheduled = false;
4132
+ var destination = request.destination;
4133
+
4134
+ if (destination) {
4135
+ flushCompletedChunks(request, destination);
4136
+ }
4037
4137
  });
4038
4138
  }
4039
4139
  }
@@ -4069,15 +4169,17 @@ function stopFlowing(request) {
4069
4169
 
4070
4170
  function abort(request, reason) {
4071
4171
  try {
4172
+ request.status = ABORTING;
4072
4173
  var abortableTasks = request.abortableTasks; // We have tasks to abort. We'll emit one error row and then emit a reference
4073
4174
  // to that row from every row that's still remaining.
4074
4175
 
4075
4176
  if (abortableTasks.size > 0) {
4076
4177
  request.pendingChunks++;
4077
4178
  var errorId = request.nextChunkId++;
4179
+ request.fatalError = errorId;
4078
4180
 
4079
4181
  var postponeInstance; if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
4080
- var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
4182
+ var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : typeof reason === 'object' && reason !== null && typeof reason.then === 'function' ? new Error('The render was aborted by the server with a promise.') : reason;
4081
4183
  var digest = logRecoverableError(request, error);
4082
4184
  emitErrorChunk(request, errorId, digest, error);
4083
4185
  }
@@ -4094,7 +4196,7 @@ function abort(request, reason) {
4094
4196
  var _error;
4095
4197
 
4096
4198
  if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
4097
- _error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
4199
+ _error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : typeof reason === 'object' && reason !== null && typeof reason.then === 'function' ? new Error('The render was aborted by the server with a promise.') : reason;
4098
4200
  }
4099
4201
 
4100
4202
  abortListeners.forEach(function (callback) {
@@ -10,7 +10,21 @@
10
10
 
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
- React = require("react"),
13
+ React = require("react");
14
+ function handleErrorInNextTick(error) {
15
+ setTimeout(function () {
16
+ throw error;
17
+ });
18
+ }
19
+ var LocalPromise = Promise,
20
+ scheduleMicrotask =
21
+ "function" === typeof queueMicrotask
22
+ ? queueMicrotask
23
+ : function (callback) {
24
+ LocalPromise.resolve(null)
25
+ .then(callback)
26
+ .catch(handleErrorInNextTick);
27
+ },
14
28
  currentView = null,
15
29
  writtenBytes = 0;
16
30
  function writeChunkAndReturn(destination, chunk) {
@@ -677,7 +691,8 @@ if (!ReactSharedInternalsServer)
677
691
  'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
678
692
  );
679
693
  var ObjectPrototype = Object.prototype,
680
- stringify = JSON.stringify;
694
+ stringify = JSON.stringify,
695
+ AbortSigil = {};
681
696
  function defaultErrorHandler(error) {
682
697
  console.error(error);
683
698
  }
@@ -761,6 +776,14 @@ function serializeThenable(request, task, thenable) {
761
776
  newTask.id
762
777
  );
763
778
  default:
779
+ if (1 === request.status)
780
+ return (
781
+ (newTask.status = 3),
782
+ (task = stringify(serializeByValueID(request.fatalError))),
783
+ emitModelChunk(request, newTask.id, task),
784
+ request.abortableTasks.delete(newTask),
785
+ newTask.id
786
+ );
764
787
  "string" !== typeof thenable.status &&
765
788
  ((thenable.status = "pending"),
766
789
  thenable.then(
@@ -947,6 +970,7 @@ function renderFunctionComponent(request, task, key, Component, props) {
947
970
  thenableIndexCounter = 0;
948
971
  thenableState = prevThenableState;
949
972
  Component = Component(props, void 0);
973
+ if (1 === request.status) throw AbortSigil;
950
974
  if (
951
975
  "object" === typeof Component &&
952
976
  null !== Component &&
@@ -1044,6 +1068,7 @@ function renderElement(request, task, type, key, ref, props) {
1044
1068
  case REACT_LAZY_TYPE:
1045
1069
  var init = type._init;
1046
1070
  type = init(type._payload);
1071
+ if (1 === request.status) throw AbortSigil;
1047
1072
  return renderElement(request, task, type, key, ref, props);
1048
1073
  case REACT_FORWARD_REF_TYPE:
1049
1074
  return renderFunctionComponent(request, task, key, type.render, props);
@@ -1060,9 +1085,9 @@ function pingTask(request, task) {
1060
1085
  pingedTasks.push(task);
1061
1086
  1 === pingedTasks.length &&
1062
1087
  ((request.flushScheduled = null !== request.destination),
1063
- setTimeout(function () {
1088
+ scheduleMicrotask(function () {
1064
1089
  return performWork(request);
1065
- }, 0));
1090
+ }));
1066
1091
  }
1067
1092
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1068
1093
  request.pendingChunks++;
@@ -1094,50 +1119,61 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1094
1119
  );
1095
1120
  } catch (thrownValue) {
1096
1121
  if (
1097
- ((parentPropertyName =
1122
+ ((parentPropertyName = task.model),
1123
+ (parentPropertyName =
1124
+ "object" === typeof parentPropertyName &&
1125
+ null !== parentPropertyName &&
1126
+ (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1127
+ parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1128
+ (value =
1098
1129
  thrownValue === SuspenseException
1099
1130
  ? getSuspendedThenable()
1100
1131
  : thrownValue),
1101
- (value = task.model),
1102
- (value =
1103
- "object" === typeof value &&
1132
+ "object" === typeof value &&
1104
1133
  null !== value &&
1105
- (value.$$typeof === REACT_ELEMENT_TYPE ||
1106
- value.$$typeof === REACT_LAZY_TYPE)),
1107
- "object" === typeof parentPropertyName &&
1108
- null !== parentPropertyName &&
1109
- "function" === typeof parentPropertyName.then)
1110
- ) {
1111
- JSCompiler_inline_result = createTask(
1112
- request,
1113
- task.model,
1114
- task.keyPath,
1115
- task.implicitSlot,
1116
- request.abortableTasks
1117
- );
1118
- var ping = JSCompiler_inline_result.ping;
1119
- parentPropertyName.then(ping, ping);
1120
- JSCompiler_inline_result.thenableState =
1121
- getThenableStateAfterSuspending();
1122
- task.keyPath = prevKeyPath;
1123
- task.implicitSlot = prevImplicitSlot;
1124
- JSCompiler_inline_result = value
1125
- ? "$L" + JSCompiler_inline_result.id.toString(16)
1126
- : serializeByValueID(JSCompiler_inline_result.id);
1127
- } else if (
1134
+ "function" === typeof value.then)
1135
+ )
1136
+ if (1 === request.status)
1137
+ (task.status = 3),
1138
+ (prevKeyPath = request.fatalError),
1139
+ (JSCompiler_inline_result = parentPropertyName
1140
+ ? "$L" + prevKeyPath.toString(16)
1141
+ : serializeByValueID(prevKeyPath));
1142
+ else {
1143
+ JSCompiler_inline_result = createTask(
1144
+ request,
1145
+ task.model,
1146
+ task.keyPath,
1147
+ task.implicitSlot,
1148
+ request.abortableTasks
1149
+ );
1150
+ var ping = JSCompiler_inline_result.ping;
1151
+ value.then(ping, ping);
1152
+ JSCompiler_inline_result.thenableState =
1153
+ getThenableStateAfterSuspending();
1154
+ task.keyPath = prevKeyPath;
1155
+ task.implicitSlot = prevImplicitSlot;
1156
+ JSCompiler_inline_result = parentPropertyName
1157
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1158
+ : serializeByValueID(JSCompiler_inline_result.id);
1159
+ }
1160
+ else if (thrownValue === AbortSigil)
1161
+ (task.status = 3),
1162
+ (prevKeyPath = request.fatalError),
1163
+ (JSCompiler_inline_result = parentPropertyName
1164
+ ? "$L" + prevKeyPath.toString(16)
1165
+ : serializeByValueID(prevKeyPath));
1166
+ else if (
1128
1167
  ((task.keyPath = prevKeyPath),
1129
1168
  (task.implicitSlot = prevImplicitSlot),
1130
- value)
1169
+ parentPropertyName)
1131
1170
  )
1132
1171
  request.pendingChunks++,
1133
1172
  (prevKeyPath = request.nextChunkId++),
1134
- (prevImplicitSlot = logRecoverableError(
1135
- request,
1136
- parentPropertyName
1137
- )),
1173
+ (prevImplicitSlot = logRecoverableError(request, value)),
1138
1174
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1139
1175
  (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1140
- else throw parentPropertyName;
1176
+ else throw value;
1141
1177
  }
1142
1178
  return JSCompiler_inline_result;
1143
1179
  },
@@ -1290,12 +1326,11 @@ function renderModelDestructive(
1290
1326
  parentPropertyName
1291
1327
  );
1292
1328
  case REACT_LAZY_TYPE:
1293
- return (
1294
- (task.thenableState = null),
1295
- (parentPropertyName = value._init),
1296
- (value = parentPropertyName(value._payload)),
1297
- renderModelDestructive(request, task, emptyRoot, "", value)
1298
- );
1329
+ task.thenableState = null;
1330
+ parentPropertyName = value._init;
1331
+ value = parentPropertyName(value._payload);
1332
+ if (1 === request.status) throw AbortSigil;
1333
+ return renderModelDestructive(request, task, emptyRoot, "", value);
1299
1334
  case REACT_LEGACY_ELEMENT_TYPE:
1300
1335
  throw Error(
1301
1336
  'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.'
@@ -1558,8 +1593,8 @@ function logRecoverableError(request, error) {
1558
1593
  }
1559
1594
  function fatalError(request, error) {
1560
1595
  null !== request.destination
1561
- ? ((request.status = 2), closeWithError(request.destination, error))
1562
- : ((request.status = 1), (request.fatalError = error));
1596
+ ? ((request.status = 3), closeWithError(request.destination, error))
1597
+ : ((request.status = 2), (request.fatalError = error));
1563
1598
  }
1564
1599
  function emitErrorChunk(request, id, digest) {
1565
1600
  digest = { digest: digest };
@@ -1628,7 +1663,8 @@ function emitChunk(request, task, value) {
1628
1663
  }
1629
1664
  var emptyRoot = {};
1630
1665
  function retryTask(request, task) {
1631
- if (0 === task.status)
1666
+ if (0 === task.status) {
1667
+ task.status = 5;
1632
1668
  try {
1633
1669
  modelRoot = task.model;
1634
1670
  var resolvedModel = renderModelDestructive(
@@ -1655,10 +1691,23 @@ function retryTask(request, task) {
1655
1691
  thrownValue === SuspenseException
1656
1692
  ? getSuspendedThenable()
1657
1693
  : thrownValue;
1658
- if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1659
- var ping = task.ping;
1660
- x.then(ping, ping);
1661
- task.thenableState = getThenableStateAfterSuspending();
1694
+ if ("object" === typeof x && null !== x && "function" === typeof x.then)
1695
+ if (1 === request.status) {
1696
+ request.abortableTasks.delete(task);
1697
+ task.status = 3;
1698
+ var model = stringify(serializeByValueID(request.fatalError));
1699
+ emitModelChunk(request, task.id, model);
1700
+ } else {
1701
+ task.status = 0;
1702
+ task.thenableState = getThenableStateAfterSuspending();
1703
+ var ping = task.ping;
1704
+ x.then(ping, ping);
1705
+ }
1706
+ else if (x === AbortSigil) {
1707
+ request.abortableTasks.delete(task);
1708
+ task.status = 3;
1709
+ var model$19 = stringify(serializeByValueID(request.fatalError));
1710
+ emitModelChunk(request, task.id, model$19);
1662
1711
  } else {
1663
1712
  request.abortableTasks.delete(task);
1664
1713
  task.status = 4;
@@ -1667,6 +1716,7 @@ function retryTask(request, task) {
1667
1716
  }
1668
1717
  } finally {
1669
1718
  }
1719
+ }
1670
1720
  }
1671
1721
  function performWork(request) {
1672
1722
  var prevDispatcher = ReactSharedInternalsServer.H;
@@ -1724,7 +1774,7 @@ function flushCompletedChunks(request, destination) {
1724
1774
  (writtenBytes = 0));
1725
1775
  }
1726
1776
  0 === request.pendingChunks &&
1727
- (destination.close(), (request.destination = null));
1777
+ ((request.status = 3), destination.close(), (request.destination = null));
1728
1778
  }
1729
1779
  function startWork(request) {
1730
1780
  request.flushScheduled = null !== request.destination;
@@ -1737,53 +1787,63 @@ function startWork(request) {
1737
1787
  }, 0);
1738
1788
  }
1739
1789
  function enqueueFlush(request) {
1740
- if (
1741
- !1 === request.flushScheduled &&
1790
+ !1 === request.flushScheduled &&
1742
1791
  0 === request.pingedTasks.length &&
1743
- null !== request.destination
1744
- ) {
1745
- var destination = request.destination;
1746
- request.flushScheduled = !0;
1792
+ null !== request.destination &&
1793
+ ((request.flushScheduled = !0),
1747
1794
  setTimeout(function () {
1748
- return flushCompletedChunks(request, destination);
1749
- }, 0);
1750
- }
1795
+ request.flushScheduled = !1;
1796
+ var destination = request.destination;
1797
+ destination && flushCompletedChunks(request, destination);
1798
+ }, 0));
1751
1799
  }
1752
1800
  function abort(request, reason) {
1753
1801
  try {
1802
+ request.status = 1;
1754
1803
  var abortableTasks = request.abortableTasks;
1755
1804
  if (0 < abortableTasks.size) {
1756
1805
  request.pendingChunks++;
1757
- var errorId = request.nextChunkId++,
1758
- error =
1806
+ var errorId = request.nextChunkId++;
1807
+ request.fatalError = errorId;
1808
+ var error =
1759
1809
  void 0 === reason
1760
1810
  ? Error("The render was aborted by the server without a reason.")
1811
+ : "object" === typeof reason &&
1812
+ null !== reason &&
1813
+ "function" === typeof reason.then
1814
+ ? Error("The render was aborted by the server with a promise.")
1761
1815
  : reason,
1762
1816
  digest = logRecoverableError(request, error);
1763
1817
  emitErrorChunk(request, errorId, digest, error);
1764
1818
  abortableTasks.forEach(function (task) {
1765
- task.status = 3;
1766
- var ref = serializeByValueID(errorId);
1767
- task = encodeReferenceChunk(request, task.id, ref);
1768
- request.completedErrorChunks.push(task);
1819
+ if (5 !== task.status) {
1820
+ task.status = 3;
1821
+ var ref = serializeByValueID(errorId);
1822
+ task = encodeReferenceChunk(request, task.id, ref);
1823
+ request.completedErrorChunks.push(task);
1824
+ }
1769
1825
  });
1770
1826
  abortableTasks.clear();
1771
1827
  }
1772
1828
  var abortListeners = request.abortListeners;
1773
1829
  if (0 < abortListeners.size) {
1774
- var error$22 =
1830
+ var error$26 =
1775
1831
  void 0 === reason
1776
1832
  ? Error("The render was aborted by the server without a reason.")
1833
+ : "object" === typeof reason &&
1834
+ null !== reason &&
1835
+ "function" === typeof reason.then
1836
+ ? Error("The render was aborted by the server with a promise.")
1777
1837
  : reason;
1778
1838
  abortListeners.forEach(function (callback) {
1779
- return callback(error$22);
1839
+ return callback(error$26);
1780
1840
  });
1781
1841
  abortListeners.clear();
1782
1842
  }
1783
1843
  null !== request.destination &&
1784
1844
  flushCompletedChunks(request, request.destination);
1785
- } catch (error$23) {
1786
- logRecoverableError(request, error$23), fatalError(request, error$23);
1845
+ } catch (error$27) {
1846
+ logRecoverableError(request, error$27), fatalError(request, error$27);
1787
1847
  }
1788
1848
  }
1789
1849
  function resolveServerReference(bundlerConfig, id) {
@@ -2226,8 +2286,8 @@ function parseReadableStream(response, reference, type) {
2226
2286
  (previousBlockedChunk = chunk));
2227
2287
  } else {
2228
2288
  chunk = previousBlockedChunk;
2229
- var chunk$26 = createPendingChunk(response);
2230
- chunk$26.then(
2289
+ var chunk$30 = createPendingChunk(response);
2290
+ chunk$30.then(
2231
2291
  function (v) {
2232
2292
  return controller.enqueue(v);
2233
2293
  },
@@ -2235,10 +2295,10 @@ function parseReadableStream(response, reference, type) {
2235
2295
  return controller.error(e);
2236
2296
  }
2237
2297
  );
2238
- previousBlockedChunk = chunk$26;
2298
+ previousBlockedChunk = chunk$30;
2239
2299
  chunk.then(function () {
2240
- previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2241
- resolveModelChunk(chunk$26, json, -1);
2300
+ previousBlockedChunk === chunk$30 && (previousBlockedChunk = null);
2301
+ resolveModelChunk(chunk$30, json, -1);
2242
2302
  });
2243
2303
  }
2244
2304
  },
@@ -2606,9 +2666,9 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2606
2666
  startWork(request);
2607
2667
  },
2608
2668
  pull: function (controller) {
2609
- if (1 === request.status)
2610
- (request.status = 2), closeWithError(controller, request.fatalError);
2611
- else if (2 !== request.status && null === request.destination) {
2669
+ if (2 === request.status)
2670
+ (request.status = 3), closeWithError(controller, request.fatalError);
2671
+ else if (3 !== request.status && null === request.destination) {
2612
2672
  request.destination = controller;
2613
2673
  try {
2614
2674
  flushCompletedChunks(request, controller);