vike 0.4.267-commit-7884d91 → 0.4.267-commit-5676e14
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.
|
@@ -132,6 +132,7 @@ async function renderPageServerEntryOnce(pageContextBegin, globalContext, reques
|
|
|
132
132
|
return await renderPageServerEntryRecursive(pageContextBegin, globalContext, requestId);
|
|
133
133
|
}
|
|
134
134
|
async function renderPageServerEntryRecursive(pageContextBegin, globalContext, requestId) {
|
|
135
|
+
assert(requestId);
|
|
135
136
|
catchInfiniteLoop(`[${getRequestTag(requestId)}] renderPageServerEntryRecursive()`);
|
|
136
137
|
const pageContextNominalPageBegin = fork(pageContextBegin);
|
|
137
138
|
const pageContextAddendumAbort = getPageContextAddendumAbort(pageContextBegin.pageContextsAborted);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: '0.4.267-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: '0.4.267-commit-5676e14';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.267-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.267-commit-5676e14';
|
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
export { catchInfiniteLoop };
|
|
2
|
-
import { assertUsage, assertWarning } from './assert.js';
|
|
2
|
+
import { assert, assertUsage, assertWarning } from './assert.js';
|
|
3
3
|
import { humanizeTime } from './humanizeTime.js';
|
|
4
|
-
const trackers =
|
|
4
|
+
const trackers = new Map();
|
|
5
|
+
let lastCleanup;
|
|
6
|
+
// Given these parameters, a warning is shown upon 10 calls a second on average during 5 seconds
|
|
5
7
|
const maxCalls = 99;
|
|
6
8
|
const time = 5 * 1000;
|
|
7
9
|
function catchInfiniteLoop(functionName) {
|
|
8
10
|
// Init
|
|
9
11
|
const now = new Date().getTime();
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
// Cleanup
|
|
13
|
+
if (globalThis.__VIKE__IS_CLIENT) {
|
|
14
|
+
// No cleanup on the client-side, in order to minimize client-side JavaScript (to save client-side KBs)
|
|
15
|
+
assert(trackers.size < 5);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Clean outdated trackers
|
|
19
|
+
// - On the server-side, there is an infinite amount of outdated trackers (a new tracker is created per HTTP request) => we should clean them
|
|
20
|
+
// - We don't clean upon every call: the server creates a new tracker per HTTP request, so that would cost O(n^2) — O(number of requests within `time`) per request
|
|
21
|
+
// - https://github.com/vikejs/vike/pull/3576
|
|
22
|
+
const cleanInterval = 10 * 1000;
|
|
23
|
+
lastCleanup ?? (lastCleanup = now);
|
|
24
|
+
if (now - lastCleanup > cleanInterval) {
|
|
25
|
+
trackers.forEach((tracker, key) => {
|
|
26
|
+
if (isOutdated(tracker, now))
|
|
27
|
+
trackers.delete(key);
|
|
28
|
+
});
|
|
29
|
+
lastCleanup = now;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Get/reset tracker
|
|
33
|
+
let tracker = trackers.get(functionName);
|
|
34
|
+
if (!tracker || isOutdated(tracker, now)) {
|
|
35
|
+
tracker = { count: 0, startTime: now };
|
|
36
|
+
trackers.set(functionName, tracker);
|
|
37
|
+
}
|
|
18
38
|
// Count
|
|
19
39
|
tracker.count++;
|
|
20
40
|
// Error
|
|
@@ -24,8 +44,10 @@ function catchInfiniteLoop(functionName) {
|
|
|
24
44
|
}
|
|
25
45
|
// Warning, at 50% threshold
|
|
26
46
|
if (!tracker.warned && tracker.count > maxCalls * 0.5) {
|
|
27
|
-
// Warning is shown upon 10 calls a second, on average during 5 seconds, given the default parameters
|
|
28
47
|
assertWarning(false, msg, { onlyOnce: false, showStackTrace: true });
|
|
29
48
|
tracker.warned = true;
|
|
30
49
|
}
|
|
31
50
|
}
|
|
51
|
+
function isOutdated(tracker, now) {
|
|
52
|
+
return now - tracker.startTime > time;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.267-commit-
|
|
3
|
+
"version": "0.4.267-commit-5676e14",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"@universal-deploy/store": "^0.2.2",
|
|
132
132
|
"@universal-deploy/vite": "^0.1.14",
|
|
133
133
|
"@universal-middleware/core": "^0.4.18",
|
|
134
|
-
"@universal-middleware/node": "^0.2.
|
|
134
|
+
"@universal-middleware/node": "^0.2.3",
|
|
135
135
|
"cac": "^6.0.0",
|
|
136
136
|
"convert-route": "^1.1.1",
|
|
137
137
|
"es-module-lexer": "^1.0.0",
|