@tramvai/module-common 6.68.6 → 6.77.3
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PageActionsAbortError, isPageActionsAbortError, isSilentError, ExecutionAbortError } from '@tinkoff/errors';
|
|
1
|
+
import { isTramvaiAction, ACTION_PARAMETERS } from '@tramvai/core';
|
|
2
|
+
import { PageActionsAbortError, isPageActionsAbortError, isSilentError, ExecutionAbortError, makeErrorSilent } from '@tinkoff/errors';
|
|
3
3
|
import { actionServerStateEvent } from './actionTramvaiReducer.es.js';
|
|
4
4
|
import { generateDeferredResolve, generateDeferredReject } from './deferred/clientScriptsUtils.es.js';
|
|
5
5
|
|
|
@@ -21,12 +21,17 @@ class ActionPageRunner {
|
|
|
21
21
|
}
|
|
22
22
|
// TODO stopRunAtError нужен только для редиректов на стороне сервера в экшенах. И нужно пересмотреть реализацию редиректов
|
|
23
23
|
runActions(actions, stopRunAtError = () => false) {
|
|
24
|
+
const actionNames = actions.map((action) => {
|
|
25
|
+
const parameters = isTramvaiAction(action) ? action : action[ACTION_PARAMETERS];
|
|
26
|
+
const actionName = parameters?.name ?? 'unknown';
|
|
27
|
+
return actionName;
|
|
28
|
+
});
|
|
24
29
|
return this.deps.executionContextManager.withContext(this.deps.commandLineExecutionContext(), { name: 'pageActions', values: { pageActions: true } }, (executionContext, abortController) => {
|
|
25
30
|
return new Promise((resolve, reject) => {
|
|
26
31
|
const timeoutMarker = setTimeout(() => {
|
|
27
32
|
const unfinishedActions = [];
|
|
28
33
|
this.deps.actionExecution.execution.forEach((value, key) => {
|
|
29
|
-
if (value.status === 'pending') {
|
|
34
|
+
if (actionNames.includes(key) && value.status === 'pending') {
|
|
30
35
|
unfinishedActions.push(key);
|
|
31
36
|
}
|
|
32
37
|
});
|
|
@@ -48,8 +53,8 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
48
53
|
const result = {};
|
|
49
54
|
// TODO: dehydrate only actions on first level as inner actions are running on client despite their execution on server
|
|
50
55
|
this.deps.actionExecution.execution.forEach((value, key) => {
|
|
51
|
-
//
|
|
52
|
-
if (value.status === 'success') {
|
|
56
|
+
// get completed actions values, others will be executed on client
|
|
57
|
+
if (actionNames.includes(key) && value.status === 'success') {
|
|
53
58
|
result[key] = value;
|
|
54
59
|
}
|
|
55
60
|
});
|
|
@@ -97,12 +102,16 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
97
102
|
const reasonIsObject = typeof executionContext.abortSignal.reason === 'object';
|
|
98
103
|
const timeoutError = reasonIsObject && isPageActionsAbortError(executionContext.abortSignal.reason);
|
|
99
104
|
const silentError = reasonIsObject && isSilentError(executionContext.abortSignal.reason);
|
|
105
|
+
const executionError = new ExecutionAbortError({
|
|
106
|
+
message: `Execution aborted in context "${contextName}"`,
|
|
107
|
+
contextName,
|
|
108
|
+
reason: executionContext.abortSignal.reason,
|
|
109
|
+
});
|
|
110
|
+
if (silentError) {
|
|
111
|
+
makeErrorSilent(executionError);
|
|
112
|
+
}
|
|
100
113
|
this.log[silentError ? 'info' : 'warn']({
|
|
101
|
-
error:
|
|
102
|
-
message: `Execution aborted in context "${contextName}"`,
|
|
103
|
-
contextName,
|
|
104
|
-
reason: executionContext.abortSignal.reason,
|
|
105
|
-
}),
|
|
114
|
+
error: executionError,
|
|
106
115
|
event: `action-execution-error`,
|
|
107
116
|
message: `${timeoutError ? `${actionName} has exceeded timeout of ${this.deps.limitTime}ms, execution results will be ignored` : `${actionName} execution error`}.
|
|
108
117
|
This action will be automatically executed on client - https://tramvai.dev/docs/features/data-fetching/action#synchronizing-between-server-and-client
|
|
@@ -25,12 +25,17 @@ class ActionPageRunner {
|
|
|
25
25
|
}
|
|
26
26
|
// TODO stopRunAtError нужен только для редиректов на стороне сервера в экшенах. И нужно пересмотреть реализацию редиректов
|
|
27
27
|
runActions(actions, stopRunAtError = () => false) {
|
|
28
|
+
const actionNames = actions.map((action) => {
|
|
29
|
+
const parameters = core.isTramvaiAction(action) ? action : action[core.ACTION_PARAMETERS];
|
|
30
|
+
const actionName = parameters?.name ?? 'unknown';
|
|
31
|
+
return actionName;
|
|
32
|
+
});
|
|
28
33
|
return this.deps.executionContextManager.withContext(this.deps.commandLineExecutionContext(), { name: 'pageActions', values: { pageActions: true } }, (executionContext, abortController) => {
|
|
29
34
|
return new Promise((resolve, reject) => {
|
|
30
35
|
const timeoutMarker = setTimeout(() => {
|
|
31
36
|
const unfinishedActions = [];
|
|
32
37
|
this.deps.actionExecution.execution.forEach((value, key) => {
|
|
33
|
-
if (value.status === 'pending') {
|
|
38
|
+
if (actionNames.includes(key) && value.status === 'pending') {
|
|
34
39
|
unfinishedActions.push(key);
|
|
35
40
|
}
|
|
36
41
|
});
|
|
@@ -52,8 +57,8 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
52
57
|
const result = {};
|
|
53
58
|
// TODO: dehydrate only actions on first level as inner actions are running on client despite their execution on server
|
|
54
59
|
this.deps.actionExecution.execution.forEach((value, key) => {
|
|
55
|
-
//
|
|
56
|
-
if (value.status === 'success') {
|
|
60
|
+
// get completed actions values, others will be executed on client
|
|
61
|
+
if (actionNames.includes(key) && value.status === 'success') {
|
|
57
62
|
result[key] = value;
|
|
58
63
|
}
|
|
59
64
|
});
|
|
@@ -101,12 +106,16 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
101
106
|
const reasonIsObject = typeof executionContext.abortSignal.reason === 'object';
|
|
102
107
|
const timeoutError = reasonIsObject && errors.isPageActionsAbortError(executionContext.abortSignal.reason);
|
|
103
108
|
const silentError = reasonIsObject && errors.isSilentError(executionContext.abortSignal.reason);
|
|
109
|
+
const executionError = new errors.ExecutionAbortError({
|
|
110
|
+
message: `Execution aborted in context "${contextName}"`,
|
|
111
|
+
contextName,
|
|
112
|
+
reason: executionContext.abortSignal.reason,
|
|
113
|
+
});
|
|
114
|
+
if (silentError) {
|
|
115
|
+
errors.makeErrorSilent(executionError);
|
|
116
|
+
}
|
|
104
117
|
this.log[silentError ? 'info' : 'warn']({
|
|
105
|
-
error:
|
|
106
|
-
message: `Execution aborted in context "${contextName}"`,
|
|
107
|
-
contextName,
|
|
108
|
-
reason: executionContext.abortSignal.reason,
|
|
109
|
-
}),
|
|
118
|
+
error: executionError,
|
|
110
119
|
event: `action-execution-error`,
|
|
111
120
|
message: `${timeoutError ? `${actionName} has exceeded timeout of ${this.deps.limitTime}ms, execution results will be ignored` : `${actionName} execution error`}.
|
|
112
121
|
This action will be automatically executed on client - https://tramvai.dev/docs/features/data-fetching/action#synchronizing-between-server-and-client
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createChildContainer } from '@tinkoff/dippy';
|
|
2
|
-
import { ExecutionAbortError,
|
|
2
|
+
import { isSilentError, ExecutionAbortError, makeErrorSilent } from '@tinkoff/errors';
|
|
3
3
|
import { ROOT_EXECUTION_CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
4
4
|
import { COMMAND_LINE_TIMING_INFO_TOKEN } from '@tramvai/tokens-core-private';
|
|
5
5
|
|
|
@@ -88,11 +88,17 @@ class CommandLineRunner {
|
|
|
88
88
|
await this.executeCommand(fn, command, di);
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
const silentError = error && typeof error === 'object' && isSilentError(error);
|
|
92
|
+
const executionError = new ExecutionAbortError({
|
|
93
93
|
message: 'Execution context were aborted because of one of the commands failed',
|
|
94
94
|
contextName: `command-line:${line}:${command.toString()}`,
|
|
95
|
-
|
|
95
|
+
reason: error,
|
|
96
|
+
});
|
|
97
|
+
if (silentError) {
|
|
98
|
+
makeErrorSilent(executionError);
|
|
99
|
+
}
|
|
100
|
+
// in case if any error happens during line execution results from other line handlers will not be used anyway
|
|
101
|
+
this.abortControllerByDi.get(di)?.abort(executionError);
|
|
96
102
|
throw error;
|
|
97
103
|
}
|
|
98
104
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createChildContainer } from '@tinkoff/dippy';
|
|
2
|
-
import { ExecutionAbortError,
|
|
2
|
+
import { isSilentError, ExecutionAbortError, makeErrorSilent } from '@tinkoff/errors';
|
|
3
3
|
import { ROOT_EXECUTION_CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
4
4
|
import { COMMAND_LINE_TIMING_INFO_TOKEN } from '@tramvai/tokens-core-private';
|
|
5
5
|
|
|
@@ -88,11 +88,17 @@ class CommandLineRunner {
|
|
|
88
88
|
await this.executeCommand(fn, command, di);
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
const silentError = error && typeof error === 'object' && isSilentError(error);
|
|
92
|
+
const executionError = new ExecutionAbortError({
|
|
93
93
|
message: 'Execution context were aborted because of one of the commands failed',
|
|
94
94
|
contextName: `command-line:${line}:${command.toString()}`,
|
|
95
|
-
|
|
95
|
+
reason: error,
|
|
96
|
+
});
|
|
97
|
+
if (silentError) {
|
|
98
|
+
makeErrorSilent(executionError);
|
|
99
|
+
}
|
|
100
|
+
// in case if any error happens during line execution results from other line handlers will not be used anyway
|
|
101
|
+
this.abortControllerByDi.get(di)?.abort(executionError);
|
|
96
102
|
throw error;
|
|
97
103
|
}
|
|
98
104
|
});
|
|
@@ -92,11 +92,17 @@ class CommandLineRunner {
|
|
|
92
92
|
await this.executeCommand(fn, command, di);
|
|
93
93
|
}
|
|
94
94
|
catch (error) {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const silentError = error && typeof error === 'object' && errors.isSilentError(error);
|
|
96
|
+
const executionError = new errors.ExecutionAbortError({
|
|
97
97
|
message: 'Execution context were aborted because of one of the commands failed',
|
|
98
98
|
contextName: `command-line:${line}:${command.toString()}`,
|
|
99
|
-
|
|
99
|
+
reason: error,
|
|
100
|
+
});
|
|
101
|
+
if (silentError) {
|
|
102
|
+
errors.makeErrorSilent(executionError);
|
|
103
|
+
}
|
|
104
|
+
// in case if any error happens during line execution results from other line handlers will not be used anyway
|
|
105
|
+
this.abortControllerByDi.get(di)?.abort(executionError);
|
|
100
106
|
throw error;
|
|
101
107
|
}
|
|
102
108
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.77.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -31,35 +31,35 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@akashbabu/lfu-cache": "1.0.2",
|
|
34
|
-
"@tinkoff/errors": "0.7.
|
|
35
|
-
"@tinkoff/hook-runner": "0.8.
|
|
34
|
+
"@tinkoff/errors": "0.7.2",
|
|
35
|
+
"@tinkoff/hook-runner": "0.8.2",
|
|
36
36
|
"@tinkoff/lru-cache-nano": "^7.9.0",
|
|
37
|
-
"@tinkoff/pubsub": "0.9.
|
|
38
|
-
"@tinkoff/url": "0.12.
|
|
39
|
-
"@tramvai/experiments": "6.
|
|
40
|
-
"@tramvai/module-cookie": "6.
|
|
41
|
-
"@tramvai/module-environment": "6.
|
|
42
|
-
"@tramvai/module-log": "6.
|
|
43
|
-
"@tramvai/safe-strings": "0.9.
|
|
44
|
-
"@tramvai/tokens-child-app": "6.
|
|
45
|
-
"@tramvai/tokens-common": "6.
|
|
46
|
-
"@tramvai/tokens-core-private": "6.
|
|
47
|
-
"@tramvai/tokens-metrics": "6.
|
|
48
|
-
"@tramvai/tokens-render": "6.
|
|
49
|
-
"@tramvai/tokens-router": "6.
|
|
50
|
-
"@tramvai/tokens-server-private": "6.
|
|
51
|
-
"@tramvai/types-actions-state-context": "6.
|
|
37
|
+
"@tinkoff/pubsub": "0.9.1",
|
|
38
|
+
"@tinkoff/url": "0.12.2",
|
|
39
|
+
"@tramvai/experiments": "6.77.3",
|
|
40
|
+
"@tramvai/module-cookie": "6.77.3",
|
|
41
|
+
"@tramvai/module-environment": "6.77.3",
|
|
42
|
+
"@tramvai/module-log": "6.77.3",
|
|
43
|
+
"@tramvai/safe-strings": "0.9.1",
|
|
44
|
+
"@tramvai/tokens-child-app": "6.77.3",
|
|
45
|
+
"@tramvai/tokens-common": "6.77.3",
|
|
46
|
+
"@tramvai/tokens-core-private": "6.77.3",
|
|
47
|
+
"@tramvai/tokens-metrics": "6.77.3",
|
|
48
|
+
"@tramvai/tokens-render": "6.77.3",
|
|
49
|
+
"@tramvai/tokens-router": "6.77.3",
|
|
50
|
+
"@tramvai/tokens-server-private": "6.77.3",
|
|
51
|
+
"@tramvai/types-actions-state-context": "6.77.3",
|
|
52
52
|
"hoist-non-react-statics": "^3.3.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@tinkoff/dippy": "0.12.
|
|
55
|
+
"@tinkoff/dippy": "0.12.6",
|
|
56
56
|
"@tinkoff/utils": "^2.1.2",
|
|
57
|
-
"@tramvai/cli": "6.
|
|
58
|
-
"@tramvai/core": "6.
|
|
59
|
-
"@tramvai/papi": "6.
|
|
60
|
-
"@tramvai/react": "6.
|
|
61
|
-
"@tramvai/state": "6.
|
|
62
|
-
"@tramvai/tokens-server": "6.
|
|
57
|
+
"@tramvai/cli": "6.77.3",
|
|
58
|
+
"@tramvai/core": "6.77.3",
|
|
59
|
+
"@tramvai/papi": "6.77.3",
|
|
60
|
+
"@tramvai/react": "6.77.3",
|
|
61
|
+
"@tramvai/state": "6.77.3",
|
|
62
|
+
"@tramvai/tokens-server": "6.77.3",
|
|
63
63
|
"react": ">=16.14.0",
|
|
64
64
|
"tslib": "^2.4.0"
|
|
65
65
|
},
|