react-server-dom-webpack 19.0.0-rc-99da76f23a-20240606 → 19.0.0-rc-cc1ec60d0d-20240607
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.
- package/cjs/react-server-dom-webpack-client.browser.development.js +9 -2
- package/cjs/react-server-dom-webpack-client.edge.development.js +9 -2
- package/cjs/react-server-dom-webpack-client.node.development.js +9 -2
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +9 -2
- package/cjs/react-server-dom-webpack-server.browser.development.js +134 -19
- package/cjs/react-server-dom-webpack-server.browser.production.js +156 -77
- package/cjs/react-server-dom-webpack-server.edge.development.js +120 -18
- package/cjs/react-server-dom-webpack-server.edge.production.js +138 -78
- package/cjs/react-server-dom-webpack-server.node.development.js +111 -18
- package/cjs/react-server-dom-webpack-server.node.production.js +133 -84
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +111 -18
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +133 -84
- package/package.json +3 -3
@@ -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
|
-
|
1088
|
+
scheduleMicrotask(function () {
|
1064
1089
|
return performWork(request);
|
1065
|
-
}
|
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
|
-
|
1102
|
-
(value =
|
1103
|
-
"object" === typeof value &&
|
1132
|
+
"object" === typeof value &&
|
1104
1133
|
null !== value &&
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
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
|
-
|
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
|
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
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
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 =
|
1562
|
-
: ((request.status =
|
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
|
-
|
1660
|
-
|
1661
|
-
|
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
|
-
|
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
|
-
|
1749
|
-
|
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
|
-
|
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
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
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$
|
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$
|
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$
|
1786
|
-
logRecoverableError(request, error$
|
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$
|
2230
|
-
chunk$
|
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$
|
2298
|
+
previousBlockedChunk = chunk$30;
|
2239
2299
|
chunk.then(function () {
|
2240
|
-
previousBlockedChunk === chunk$
|
2241
|
-
resolveModelChunk(chunk$
|
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 (
|
2610
|
-
(request.status =
|
2611
|
-
else if (
|
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);
|
@@ -100,6 +100,7 @@ function printWarning(level, format, args, currentStack) {
|
|
100
100
|
function scheduleWork(callback) {
|
101
101
|
setImmediate(callback);
|
102
102
|
}
|
103
|
+
var scheduleMicrotask = queueMicrotask;
|
103
104
|
function flushBuffered(destination) {
|
104
105
|
// If we don't have any more data to send right now.
|
105
106
|
// Flush whatever is in the buffer to the wire.
|
@@ -1632,6 +1633,8 @@ var PENDING$1 = 0;
|
|
1632
1633
|
var COMPLETED = 1;
|
1633
1634
|
var ABORTED = 3;
|
1634
1635
|
var ERRORED$1 = 4;
|
1636
|
+
var RENDERING = 5;
|
1637
|
+
var AbortSigil = {};
|
1635
1638
|
|
1636
1639
|
function defaultErrorHandler(error) {
|
1637
1640
|
console['error'](error); // Don't transform to our wrapper
|
@@ -1641,8 +1644,9 @@ function defaultPostponeHandler(reason) {// Noop
|
|
1641
1644
|
}
|
1642
1645
|
|
1643
1646
|
var OPEN = 0;
|
1644
|
-
var
|
1645
|
-
var
|
1647
|
+
var ABORTING = 1;
|
1648
|
+
var CLOSING = 2;
|
1649
|
+
var CLOSED = 3;
|
1646
1650
|
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName, temporaryReferences) {
|
1647
1651
|
if (ReactSharedInternals.A !== null && ReactSharedInternals.A !== DefaultAsyncDispatcher) {
|
1648
1652
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
@@ -1740,6 +1744,16 @@ function serializeThenable(request, task, thenable) {
|
|
1740
1744
|
|
1741
1745
|
default:
|
1742
1746
|
{
|
1747
|
+
if (request.status === ABORTING) {
|
1748
|
+
// We can no longer accept any resolved values
|
1749
|
+
newTask.status = ABORTED;
|
1750
|
+
var errorId = request.fatalError;
|
1751
|
+
var model = stringify(serializeByValueID(errorId));
|
1752
|
+
emitModelChunk(request, newTask.id, model);
|
1753
|
+
request.abortableTasks.delete(newTask);
|
1754
|
+
return newTask.id;
|
1755
|
+
}
|
1756
|
+
|
1743
1757
|
if (typeof thenable.status === 'string') {
|
1744
1758
|
// Only instrument the thenable if the status if not defined. If
|
1745
1759
|
// it's defined, but an unknown value, assume it's been instrumented by
|
@@ -2114,6 +2128,13 @@ validated) // DEV-only
|
|
2114
2128
|
result = callComponentInDEV(Component, props, componentDebugInfo);
|
2115
2129
|
}
|
2116
2130
|
|
2131
|
+
if (request.status === ABORTING) {
|
2132
|
+
// If we aborted during rendering we should interrupt the render but
|
2133
|
+
// we don't need to provide an error because the renderer will encode
|
2134
|
+
// the abort error as the reason.
|
2135
|
+
throw AbortSigil;
|
2136
|
+
}
|
2137
|
+
|
2117
2138
|
if (typeof result === 'object' && result !== null && !isClientReference(result)) {
|
2118
2139
|
if (typeof result.then === 'function') {
|
2119
2140
|
// When the return value is in children position we can resolve it immediately,
|
@@ -2455,6 +2476,13 @@ validated) // DEV only
|
|
2455
2476
|
wrappedType = callLazyInitInDEV(type);
|
2456
2477
|
}
|
2457
2478
|
|
2479
|
+
if (request.status === ABORTING) {
|
2480
|
+
// lazy initializers are user code and could abort during render
|
2481
|
+
// we don't wan to return any value resolved from the lazy initializer
|
2482
|
+
// if it aborts so we interrupt rendering here
|
2483
|
+
throw AbortSigil;
|
2484
|
+
}
|
2485
|
+
|
2458
2486
|
return renderElement(request, task, wrappedType, key, ref, props, owner);
|
2459
2487
|
}
|
2460
2488
|
|
@@ -2479,7 +2507,7 @@ function pingTask(request, task) {
|
|
2479
2507
|
|
2480
2508
|
if (pingedTasks.length === 1) {
|
2481
2509
|
request.flushScheduled = request.destination !== null;
|
2482
|
-
|
2510
|
+
scheduleMicrotask(function () {
|
2483
2511
|
return performWork(request);
|
2484
2512
|
});
|
2485
2513
|
}
|
@@ -2777,21 +2805,32 @@ function renderModel(request, task, parent, key, value) {
|
|
2777
2805
|
try {
|
2778
2806
|
return renderModelDestructive(request, task, parent, key, value);
|
2779
2807
|
} catch (thrownValue) {
|
2808
|
+
// If the suspended/errored value was an element or lazy it can be reduced
|
2809
|
+
// to a lazy reference, so that it doesn't error the parent.
|
2810
|
+
var model = task.model;
|
2811
|
+
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2780
2812
|
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2781
2813
|
// reasons, the rest of the Suspense implementation expects the thrown
|
2782
2814
|
// value to be a thenable, because before `use` existed that was the
|
2783
2815
|
// (unstable) API for suspending. This implementation detail can change
|
2784
2816
|
// later, once we deprecate the old API in favor of `use`.
|
2785
|
-
getSuspendedThenable() : thrownValue;
|
2786
|
-
// to a lazy reference, so that it doesn't error the parent.
|
2787
|
-
|
2788
|
-
var model = task.model;
|
2789
|
-
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2817
|
+
getSuspendedThenable() : thrownValue;
|
2790
2818
|
|
2791
2819
|
if (typeof x === 'object' && x !== null) {
|
2792
2820
|
// $FlowFixMe[method-unbinding]
|
2793
2821
|
if (typeof x.then === 'function') {
|
2794
|
-
|
2822
|
+
if (request.status === ABORTING) {
|
2823
|
+
task.status = ABORTED;
|
2824
|
+
var errorId = request.fatalError;
|
2825
|
+
|
2826
|
+
if (wasReactNode) {
|
2827
|
+
return serializeLazyID(errorId);
|
2828
|
+
}
|
2829
|
+
|
2830
|
+
return serializeByValueID(errorId);
|
2831
|
+
} // Something suspended, we'll need to create a new task and resolve it later.
|
2832
|
+
|
2833
|
+
|
2795
2834
|
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2796
2835
|
var ping = newTask.ping;
|
2797
2836
|
x.then(ping, ping);
|
@@ -2807,6 +2846,17 @@ function renderModel(request, task, parent, key, value) {
|
|
2807
2846
|
|
2808
2847
|
return serializeByValueID(newTask.id);
|
2809
2848
|
}
|
2849
|
+
}
|
2850
|
+
|
2851
|
+
if (thrownValue === AbortSigil) {
|
2852
|
+
task.status = ABORTED;
|
2853
|
+
var _errorId = request.fatalError;
|
2854
|
+
|
2855
|
+
if (wasReactNode) {
|
2856
|
+
return serializeLazyID(_errorId);
|
2857
|
+
}
|
2858
|
+
|
2859
|
+
return serializeByValueID(_errorId);
|
2810
2860
|
} // Restore the context. We assume that this will be restored by the inner
|
2811
2861
|
// functions in case nothing throws so we don't use "finally" here.
|
2812
2862
|
|
@@ -2819,10 +2869,12 @@ function renderModel(request, task, parent, key, value) {
|
|
2819
2869
|
// We'll replace this element with a lazy reference that throws on the client
|
2820
2870
|
// once it gets rendered.
|
2821
2871
|
request.pendingChunks++;
|
2822
|
-
|
2872
|
+
|
2873
|
+
var _errorId2 = request.nextChunkId++;
|
2874
|
+
|
2823
2875
|
var digest = logRecoverableError(request, x);
|
2824
|
-
emitErrorChunk(request,
|
2825
|
-
return serializeLazyID(
|
2876
|
+
emitErrorChunk(request, _errorId2, digest, x);
|
2877
|
+
return serializeLazyID(_errorId2);
|
2826
2878
|
} // Something errored but it was not in a React Node. There's no need to serialize
|
2827
2879
|
// it by value because it'll just error the whole parent row anyway so we can
|
2828
2880
|
// just stop any siblings and error the whole parent row.
|
@@ -2926,6 +2978,13 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2926
2978
|
resolvedModel = callLazyInitInDEV(lazy);
|
2927
2979
|
}
|
2928
2980
|
|
2981
|
+
if (request.status === ABORTING) {
|
2982
|
+
// lazy initializers are user code and could abort during render
|
2983
|
+
// we don't wan to return any value resolved from the lazy initializer
|
2984
|
+
// if it aborts so we interrupt rendering here
|
2985
|
+
throw AbortSigil;
|
2986
|
+
}
|
2987
|
+
|
2929
2988
|
{
|
2930
2989
|
var _debugInfo = lazy._debugInfo;
|
2931
2990
|
|
@@ -3836,6 +3895,7 @@ function retryTask(request, task) {
|
|
3836
3895
|
}
|
3837
3896
|
|
3838
3897
|
var prevDebugID = debugID;
|
3898
|
+
task.status = RENDERING;
|
3839
3899
|
|
3840
3900
|
try {
|
3841
3901
|
// Track the root so we know that we have to emit this object even though it
|
@@ -3892,14 +3952,35 @@ function retryTask(request, task) {
|
|
3892
3952
|
if (typeof x === 'object' && x !== null) {
|
3893
3953
|
// $FlowFixMe[method-unbinding]
|
3894
3954
|
if (typeof x.then === 'function') {
|
3895
|
-
|
3955
|
+
if (request.status === ABORTING) {
|
3956
|
+
request.abortableTasks.delete(task);
|
3957
|
+
task.status = ABORTED;
|
3958
|
+
var errorId = request.fatalError;
|
3959
|
+
var model = stringify(serializeByValueID(errorId));
|
3960
|
+
emitModelChunk(request, task.id, model);
|
3961
|
+
return;
|
3962
|
+
} // Something suspended again, let's pick it back up later.
|
3963
|
+
|
3964
|
+
|
3965
|
+
task.status = PENDING$1;
|
3966
|
+
task.thenableState = getThenableStateAfterSuspending();
|
3896
3967
|
var ping = task.ping;
|
3897
3968
|
x.then(ping, ping);
|
3898
|
-
task.thenableState = getThenableStateAfterSuspending();
|
3899
3969
|
return;
|
3900
3970
|
}
|
3901
3971
|
}
|
3902
3972
|
|
3973
|
+
if (x === AbortSigil) {
|
3974
|
+
request.abortableTasks.delete(task);
|
3975
|
+
task.status = ABORTED;
|
3976
|
+
var _errorId3 = request.fatalError;
|
3977
|
+
|
3978
|
+
var _model = stringify(serializeByValueID(_errorId3));
|
3979
|
+
|
3980
|
+
emitModelChunk(request, task.id, _model);
|
3981
|
+
return;
|
3982
|
+
}
|
3983
|
+
|
3903
3984
|
request.abortableTasks.delete(task);
|
3904
3985
|
task.status = ERRORED$1;
|
3905
3986
|
var digest = logRecoverableError(request, x);
|
@@ -3961,6 +4042,11 @@ function performWork(request) {
|
|
3961
4042
|
}
|
3962
4043
|
|
3963
4044
|
function abortTask(task, request, errorId) {
|
4045
|
+
if (task.status === RENDERING) {
|
4046
|
+
// This task will be aborted by the render
|
4047
|
+
return;
|
4048
|
+
}
|
4049
|
+
|
3964
4050
|
task.status = ABORTED; // Instead of emitting an error per task.id, we emit a model that only
|
3965
4051
|
// has a single value referencing the error.
|
3966
4052
|
|
@@ -4055,6 +4141,7 @@ function flushCompletedChunks(request, destination) {
|
|
4055
4141
|
|
4056
4142
|
if (request.pendingChunks === 0) {
|
4057
4143
|
|
4144
|
+
request.status = CLOSED;
|
4058
4145
|
close$1(destination);
|
4059
4146
|
request.destination = null;
|
4060
4147
|
}
|
@@ -4075,10 +4162,14 @@ function enqueueFlush(request) {
|
|
4075
4162
|
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
|
4076
4163
|
// happen when we start flowing again
|
4077
4164
|
request.destination !== null) {
|
4078
|
-
var destination = request.destination;
|
4079
4165
|
request.flushScheduled = true;
|
4080
4166
|
scheduleWork(function () {
|
4081
|
-
|
4167
|
+
request.flushScheduled = false;
|
4168
|
+
var destination = request.destination;
|
4169
|
+
|
4170
|
+
if (destination) {
|
4171
|
+
flushCompletedChunks(request, destination);
|
4172
|
+
}
|
4082
4173
|
});
|
4083
4174
|
}
|
4084
4175
|
}
|
@@ -4114,15 +4205,17 @@ function stopFlowing(request) {
|
|
4114
4205
|
|
4115
4206
|
function abort(request, reason) {
|
4116
4207
|
try {
|
4208
|
+
request.status = ABORTING;
|
4117
4209
|
var abortableTasks = request.abortableTasks; // We have tasks to abort. We'll emit one error row and then emit a reference
|
4118
4210
|
// to that row from every row that's still remaining.
|
4119
4211
|
|
4120
4212
|
if (abortableTasks.size > 0) {
|
4121
4213
|
request.pendingChunks++;
|
4122
4214
|
var errorId = request.nextChunkId++;
|
4215
|
+
request.fatalError = errorId;
|
4123
4216
|
|
4124
4217
|
var postponeInstance; if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
4125
|
-
var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
4218
|
+
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;
|
4126
4219
|
var digest = logRecoverableError(request, error);
|
4127
4220
|
emitErrorChunk(request, errorId, digest, error);
|
4128
4221
|
}
|
@@ -4139,7 +4232,7 @@ function abort(request, reason) {
|
|
4139
4232
|
var _error;
|
4140
4233
|
|
4141
4234
|
if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
4142
|
-
_error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
4235
|
+
_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;
|
4143
4236
|
}
|
4144
4237
|
|
4145
4238
|
abortListeners.forEach(function (callback) {
|