@tramvai/module-common 4.33.3 → 4.34.1
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.
|
@@ -23,16 +23,18 @@ AsyncLocalStorageModule = __decorate([
|
|
|
23
23
|
return () => {
|
|
24
24
|
app.addHook('onRequest', (req, reply, done) => {
|
|
25
25
|
storage.run({}, done);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
// prevent memory leaks, because async context can be destroyed after response,
|
|
27
|
+
// all stored resources will be accumulated in memory, and peak memory allocation will be high
|
|
28
|
+
// `onResponse` is not used because is not fired when request was aborted by user (https://fastify.dev/docs/latest/Guides/Detecting-When-Clients-Abort/)
|
|
29
|
+
// TODO: can lead to errors because store will be cleared before reply, but maybe it's ok because response will be ignored?
|
|
30
|
+
reply.raw.once('close', () => {
|
|
31
|
+
const store = storage.getStore();
|
|
32
|
+
if (store) {
|
|
33
|
+
for (const key in store) {
|
|
34
|
+
delete store[key];
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
|
-
}
|
|
37
|
+
});
|
|
36
38
|
});
|
|
37
39
|
};
|
|
38
40
|
},
|
|
@@ -27,16 +27,18 @@ exports.AsyncLocalStorageModule = tslib.__decorate([
|
|
|
27
27
|
return () => {
|
|
28
28
|
app.addHook('onRequest', (req, reply, done) => {
|
|
29
29
|
storage.run({}, done);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
// prevent memory leaks, because async context can be destroyed after response,
|
|
31
|
+
// all stored resources will be accumulated in memory, and peak memory allocation will be high
|
|
32
|
+
// `onResponse` is not used because is not fired when request was aborted by user (https://fastify.dev/docs/latest/Guides/Detecting-When-Clients-Abort/)
|
|
33
|
+
// TODO: can lead to errors because store will be cleared before reply, but maybe it's ok because response will be ignored?
|
|
34
|
+
reply.raw.once('close', () => {
|
|
35
|
+
const store = storage.getStore();
|
|
36
|
+
if (store) {
|
|
37
|
+
for (const key in store) {
|
|
38
|
+
delete store[key];
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
}
|
|
41
|
+
});
|
|
40
42
|
});
|
|
41
43
|
};
|
|
42
44
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.34.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
"@tinkoff/pubsub": "0.7.1",
|
|
38
38
|
"@tinkoff/url": "0.10.1",
|
|
39
39
|
"@tramvai/safe-strings": "0.7.2",
|
|
40
|
-
"@tramvai/experiments": "4.
|
|
41
|
-
"@tramvai/module-cookie": "4.
|
|
42
|
-
"@tramvai/module-environment": "4.
|
|
43
|
-
"@tramvai/module-log": "4.
|
|
44
|
-
"@tramvai/tokens-child-app": "4.
|
|
45
|
-
"@tramvai/tokens-core-private": "4.
|
|
46
|
-
"@tramvai/tokens-common": "4.
|
|
47
|
-
"@tramvai/tokens-render": "4.
|
|
48
|
-
"@tramvai/tokens-router": "4.
|
|
49
|
-
"@tramvai/tokens-server-private": "4.
|
|
50
|
-
"@tramvai/types-actions-state-context": "4.
|
|
40
|
+
"@tramvai/experiments": "4.34.1",
|
|
41
|
+
"@tramvai/module-cookie": "4.34.1",
|
|
42
|
+
"@tramvai/module-environment": "4.34.1",
|
|
43
|
+
"@tramvai/module-log": "4.34.1",
|
|
44
|
+
"@tramvai/tokens-child-app": "4.34.1",
|
|
45
|
+
"@tramvai/tokens-core-private": "4.34.1",
|
|
46
|
+
"@tramvai/tokens-common": "4.34.1",
|
|
47
|
+
"@tramvai/tokens-render": "4.34.1",
|
|
48
|
+
"@tramvai/tokens-router": "4.34.1",
|
|
49
|
+
"@tramvai/tokens-server-private": "4.34.1",
|
|
50
|
+
"@tramvai/types-actions-state-context": "4.34.1",
|
|
51
51
|
"hoist-non-react-statics": "^3.3.1",
|
|
52
52
|
"node-abort-controller": "^3.0.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@tinkoff/dippy": "0.10.8",
|
|
56
56
|
"@tinkoff/utils": "^2.1.2",
|
|
57
|
-
"@tramvai/cli": "4.
|
|
58
|
-
"@tramvai/core": "4.
|
|
59
|
-
"@tramvai/papi": "4.
|
|
60
|
-
"@tramvai/react": "4.
|
|
61
|
-
"@tramvai/state": "4.
|
|
62
|
-
"@tramvai/tokens-server": "4.
|
|
57
|
+
"@tramvai/cli": "4.34.1",
|
|
58
|
+
"@tramvai/core": "4.34.1",
|
|
59
|
+
"@tramvai/papi": "4.34.1",
|
|
60
|
+
"@tramvai/react": "4.34.1",
|
|
61
|
+
"@tramvai/state": "4.34.1",
|
|
62
|
+
"@tramvai/tokens-server": "4.34.1",
|
|
63
63
|
"react": ">=16.14.0",
|
|
64
64
|
"tslib": "^2.4.0"
|
|
65
65
|
},
|