@tramvai/module-server 6.79.5 → 6.79.6
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.
|
@@ -6,21 +6,23 @@ import { prepareLogsForError } from './prepareLogsForError.es.js';
|
|
|
6
6
|
import { renderErrorBoundaryPageToString } from './renderErrorBoundaryPageToString.es.js';
|
|
7
7
|
|
|
8
8
|
const errorHandler = async (app, { log, beforeError, afterError, fetchWebpackStats, staticRootErrorBoundaryError, }) => {
|
|
9
|
-
const webpackStats = await fetchWebpackStats();
|
|
10
9
|
const RootErrorBoundary = getRootErrorBoundary();
|
|
11
10
|
const isRootErrorBoundaryExist = RootErrorBoundary !== null;
|
|
12
11
|
if (process.env.TRAMVAI_CLI_COMMAND === 'static' && isRootErrorBoundaryExist) {
|
|
13
12
|
serveRootErrorBoundary({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
render: async () => {
|
|
14
|
+
const webpackStats = await fetchWebpackStats();
|
|
15
|
+
return renderErrorBoundaryPageToString({
|
|
16
|
+
element: RootErrorBoundary,
|
|
17
|
+
requestUrl: '/5xx.html',
|
|
18
|
+
error: staticRootErrorBoundaryError ?? {
|
|
19
|
+
name: 'STATIC_ROOT_ERROR_BOUNDARY_ERROR',
|
|
20
|
+
message: 'Default error for root error boundary',
|
|
21
|
+
},
|
|
22
|
+
httpStatus: 500,
|
|
23
|
+
webpackStats,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
24
26
|
app,
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -61,6 +63,7 @@ More information about redirects - https://tramvai.dev/docs/features/routing/red
|
|
|
61
63
|
reply.status(httpStatus);
|
|
62
64
|
if (isRootErrorBoundaryExist) {
|
|
63
65
|
try {
|
|
66
|
+
const webpackStats = await fetchWebpackStats();
|
|
64
67
|
const response = renderErrorBoundaryPageToString({
|
|
65
68
|
element: RootErrorBoundary,
|
|
66
69
|
requestUrl: requestInfo.url,
|
|
@@ -14,21 +14,23 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
14
|
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
15
15
|
|
|
16
16
|
const errorHandler = async (app, { log, beforeError, afterError, fetchWebpackStats, staticRootErrorBoundaryError, }) => {
|
|
17
|
-
const webpackStats = await fetchWebpackStats();
|
|
18
17
|
const RootErrorBoundary = utils.getRootErrorBoundary();
|
|
19
18
|
const isRootErrorBoundaryExist = RootErrorBoundary !== null;
|
|
20
19
|
if (process.env.TRAMVAI_CLI_COMMAND === 'static' && isRootErrorBoundaryExist) {
|
|
21
20
|
serveRootErrorBoundary.serveRootErrorBoundary({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
render: async () => {
|
|
22
|
+
const webpackStats = await fetchWebpackStats();
|
|
23
|
+
return renderErrorBoundaryPageToString.renderErrorBoundaryPageToString({
|
|
24
|
+
element: RootErrorBoundary,
|
|
25
|
+
requestUrl: '/5xx.html',
|
|
26
|
+
error: staticRootErrorBoundaryError ?? {
|
|
27
|
+
name: 'STATIC_ROOT_ERROR_BOUNDARY_ERROR',
|
|
28
|
+
message: 'Default error for root error boundary',
|
|
29
|
+
},
|
|
30
|
+
httpStatus: 500,
|
|
31
|
+
webpackStats,
|
|
32
|
+
});
|
|
33
|
+
},
|
|
32
34
|
app,
|
|
33
35
|
});
|
|
34
36
|
}
|
|
@@ -69,6 +71,7 @@ More information about redirects - https://tramvai.dev/docs/features/routing/red
|
|
|
69
71
|
reply.status(httpStatus);
|
|
70
72
|
if (isRootErrorBoundaryExist) {
|
|
71
73
|
try {
|
|
74
|
+
const webpackStats = await fetchWebpackStats();
|
|
72
75
|
const response = renderErrorBoundaryPageToString.renderErrorBoundaryPageToString({
|
|
73
76
|
element: RootErrorBoundary,
|
|
74
77
|
requestUrl: requestInfo.url,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
export declare function serveRootErrorBoundary({
|
|
3
|
-
|
|
2
|
+
export declare function serveRootErrorBoundary({ render, app, }: {
|
|
3
|
+
render: () => Promise<string>;
|
|
4
4
|
app: FastifyInstance;
|
|
5
5
|
}): void;
|
|
6
6
|
//# sourceMappingURL=serveRootErrorBoundary.d.ts.map
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
function serveRootErrorBoundary({
|
|
1
|
+
function serveRootErrorBoundary({ render, app, }) {
|
|
2
|
+
// Error page is static so we can cache it
|
|
3
|
+
let response;
|
|
4
|
+
// Warm up error page on startup
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
if (!response) {
|
|
7
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
8
|
+
render().then((res) => {
|
|
9
|
+
response = res;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}, 0);
|
|
2
13
|
app.register(async (instance) => {
|
|
3
|
-
instance.all('/_errors/5xx', (request, reply) => {
|
|
14
|
+
instance.all('/_errors/5xx', async (request, reply) => {
|
|
15
|
+
if (!response) {
|
|
16
|
+
response = await render();
|
|
17
|
+
}
|
|
4
18
|
reply.status(200);
|
|
5
19
|
reply.header('Content-Type', 'text/html; charset=utf-8');
|
|
6
20
|
reply.header('Content-Length', Buffer.byteLength(response, 'utf8'));
|
|
@@ -2,9 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function serveRootErrorBoundary({
|
|
5
|
+
function serveRootErrorBoundary({ render, app, }) {
|
|
6
|
+
// Error page is static so we can cache it
|
|
7
|
+
let response;
|
|
8
|
+
// Warm up error page on startup
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
if (!response) {
|
|
11
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
12
|
+
render().then((res) => {
|
|
13
|
+
response = res;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}, 0);
|
|
6
17
|
app.register(async (instance) => {
|
|
7
|
-
instance.all('/_errors/5xx', (request, reply) => {
|
|
18
|
+
instance.all('/_errors/5xx', async (request, reply) => {
|
|
19
|
+
if (!response) {
|
|
20
|
+
response = await render();
|
|
21
|
+
}
|
|
8
22
|
reply.status(200);
|
|
9
23
|
reply.header('Content-Type', 'text/html; charset=utf-8');
|
|
10
24
|
reply.header('Content-Length', Buffer.byteLength(response, 'utf8'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-server",
|
|
3
|
-
"version": "6.79.
|
|
3
|
+
"version": "6.79.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@tinkoff/monkeypatch": "6.0.2",
|
|
31
31
|
"@tinkoff/terminus": "0.5.4",
|
|
32
32
|
"@tinkoff/url": "0.12.3",
|
|
33
|
-
"@tramvai/module-cache-warmup": "6.79.
|
|
34
|
-
"@tramvai/module-metrics": "6.79.
|
|
35
|
-
"@tramvai/papi": "6.79.
|
|
33
|
+
"@tramvai/module-cache-warmup": "6.79.6",
|
|
34
|
+
"@tramvai/module-metrics": "6.79.6",
|
|
35
|
+
"@tramvai/papi": "6.79.6",
|
|
36
36
|
"@tramvai/safe-strings": "0.9.2",
|
|
37
|
-
"@tramvai/tokens-router": "6.79.
|
|
38
|
-
"@tramvai/tokens-server": "6.79.
|
|
39
|
-
"@tramvai/tokens-server-private": "6.79.
|
|
37
|
+
"@tramvai/tokens-router": "6.79.6",
|
|
38
|
+
"@tramvai/tokens-server": "6.79.6",
|
|
39
|
+
"@tramvai/tokens-server-private": "6.79.6",
|
|
40
40
|
"afterframe": "^1.0.2",
|
|
41
41
|
"fastify": "^5.6.2",
|
|
42
42
|
"http-proxy-middleware": "^2.0.2",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@tinkoff/dippy": "0.12.7",
|
|
47
47
|
"@tinkoff/utils": "^2.1.2",
|
|
48
|
-
"@tramvai/cli": "6.79.
|
|
49
|
-
"@tramvai/core": "6.79.
|
|
50
|
-
"@tramvai/module-common": "6.79.
|
|
51
|
-
"@tramvai/module-environment": "6.79.
|
|
52
|
-
"@tramvai/react": "6.79.
|
|
53
|
-
"@tramvai/tokens-common": "6.79.
|
|
54
|
-
"@tramvai/tokens-core-private": "6.79.
|
|
55
|
-
"@tramvai/tokens-render": "6.79.
|
|
48
|
+
"@tramvai/cli": "6.79.6",
|
|
49
|
+
"@tramvai/core": "6.79.6",
|
|
50
|
+
"@tramvai/module-common": "6.79.6",
|
|
51
|
+
"@tramvai/module-environment": "6.79.6",
|
|
52
|
+
"@tramvai/react": "6.79.6",
|
|
53
|
+
"@tramvai/tokens-common": "6.79.6",
|
|
54
|
+
"@tramvai/tokens-core-private": "6.79.6",
|
|
55
|
+
"@tramvai/tokens-render": "6.79.6",
|
|
56
56
|
"react": ">=16.14.0",
|
|
57
57
|
"react-dom": ">=16.14.0",
|
|
58
58
|
"tslib": "^2.4.0"
|