.
This commit is contained in:
+66
@@ -0,0 +1,66 @@
|
||||
// This module can be shared between both pages router and app router
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
isRecoverableError: null,
|
||||
onRecoverableError: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
isRecoverableError: function() {
|
||||
return isRecoverableError;
|
||||
},
|
||||
onRecoverableError: function() {
|
||||
return onRecoverableError;
|
||||
}
|
||||
});
|
||||
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
||||
const _bailouttocsr = require("../../shared/lib/lazy-dynamic/bailout-to-csr");
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default._(require("../../lib/is-error"));
|
||||
const _reportglobalerror = require("./report-global-error");
|
||||
const recoverableErrors = new WeakSet();
|
||||
const isInstantTest = process.env.__NEXT_EXPOSE_TESTING_API && typeof self !== 'undefined' && !!self.__next_instant_test;
|
||||
function isRecoverableError(error) {
|
||||
return recoverableErrors.has(error);
|
||||
}
|
||||
const onRecoverableError = (error)=>{
|
||||
// x-ref: https://github.com/facebook/react/pull/28736
|
||||
let cause = (0, _iserror.default)(error) && 'cause' in error ? error.cause : error;
|
||||
// Skip certain custom errors which are not expected to be reported on client
|
||||
if ((0, _bailouttocsr.isBailoutToCSRError)(cause)) return;
|
||||
// Instant Navigation Testing API: suppress "server could not finish this
|
||||
// Suspense boundary" errors (React error #419) during instant test mode.
|
||||
// The static shell intentionally has incomplete Suspense boundaries — React
|
||||
// correctly falls back to client rendering, which is expected.
|
||||
if (isInstantTest) {
|
||||
if ((0, _iserror.default)(cause)) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (cause.message.includes('#419')) return;
|
||||
} else {
|
||||
if (cause.message.includes('could not finish this Suspense boundary')) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const { decorateDevError } = require('../../next-devtools/userspace/app/errors/stitched-error');
|
||||
const causeError = decorateDevError(cause);
|
||||
recoverableErrors.add(causeError);
|
||||
cause = causeError;
|
||||
}
|
||||
(0, _reportglobalerror.reportGlobalError)(cause);
|
||||
};
|
||||
|
||||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
||||
Object.defineProperty(exports.default, '__esModule', { value: true });
|
||||
Object.assign(exports.default, exports);
|
||||
module.exports = exports.default;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=on-recoverable-error.js.map
|
||||
Reference in New Issue
Block a user