@reportportal/client-javascript 5.4.1 → 5.4.2
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.
- package/README.md +21 -1
- package/VERSION +1 -1
- package/lib/rest.js +33 -6
- package/package.json +3 -3
- package/statistics/constants.js +2 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ When creating a client instance, you need to specify the following options:
|
|
|
61
61
|
| headers | Optional | {} | The object with custom headers for internal http client. |
|
|
62
62
|
| debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
|
|
63
63
|
| isLaunchMergeRequired | Optional | false | Allows client to merge launches into one at the end of the run via saving their UUIDs to the temp files at filesystem. At the end of the run launches can be merged using `mergeLaunches` method. Temp file format: `rplaunch-${launch_uuid}.tmp`. |
|
|
64
|
-
| restClientConfig | Optional | Not set | `axios` like http client [config](https://github.com/axios/axios#request-config). May contain `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, and other client options eg. `timeout`. For debugging and displaying logs you can set `debug: true`. |
|
|
64
|
+
| restClientConfig | Optional | Not set | `axios` like http client [config](https://github.com/axios/axios#request-config). May contain `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, and other client options eg. `timeout`. For debugging and displaying logs you can set `debug: true`. Use the `retry` property (number or [`axios-retry`](https://github.com/softonic/axios-retry#options) config) to customise automatic retries. |
|
|
65
65
|
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
|
|
66
66
|
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR', 'FILE', 'ENVIRONMENT'. Works only if `launchUuidPrint` set to `true`. File format: `rp-launch-uuid-${launch_uuid}.tmp`. Env variable: `RP_LAUNCH_UUID`. |
|
|
67
67
|
| token | Deprecated | Not set | Use `apiKey` instead. |
|
|
@@ -88,6 +88,26 @@ There is a timeout on axios requests. If for instance the server your making a r
|
|
|
88
88
|
|
|
89
89
|
You can simply change this timeout by adding a `timeout` property to `restClientConfig` with your desired numeric value (in _ms_) or *0* to disable it.
|
|
90
90
|
|
|
91
|
+
### Retry configuration
|
|
92
|
+
|
|
93
|
+
The client retries failed HTTP calls up to 6 times with an exponential backoff (starting at 200 ms and capping at 5 s) and resets the axios timeout before each retry. Provide a `retry` option in `restClientConfig` to change that behaviour. The value can be either a number (overriding just the retry count) or a full [`axios-retry` configuration object](https://github.com/softonic/axios-retry#options):
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
const axiosRetry = require('axios-retry').default;
|
|
97
|
+
|
|
98
|
+
const client = new RPClient({
|
|
99
|
+
// ... other options
|
|
100
|
+
restClientConfig: {
|
|
101
|
+
retry: {
|
|
102
|
+
retries: 5,
|
|
103
|
+
retryDelay: axiosRetry.exponentialDelay,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Setting `retry: 0` disables automatic retries.
|
|
110
|
+
|
|
91
111
|
### checkConnect
|
|
92
112
|
|
|
93
113
|
`checkConnect` - asynchronous method for verifying the correctness of the client connection
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.4.
|
|
1
|
+
5.4.3-SNAPSHOT
|
package/lib/rest.js
CHANGED
|
@@ -5,12 +5,17 @@ const https = require('https');
|
|
|
5
5
|
const logger = require('./logger');
|
|
6
6
|
|
|
7
7
|
const DEFAULT_MAX_CONNECTION_TIME_MS = 30000;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const DEFAULT_RETRY_ATTEMPTS = 6;
|
|
9
|
+
const RETRY_BASE_DELAY_MS = 200;
|
|
10
|
+
const RETRY_MAX_DELAY_MS = 5000;
|
|
11
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
12
|
+
retryDelay: (retryCount = 1) =>
|
|
13
|
+
Math.min(RETRY_BASE_DELAY_MS * 2 ** Math.max(retryCount - 1, 0), RETRY_MAX_DELAY_MS),
|
|
14
|
+
retries: DEFAULT_RETRY_ATTEMPTS,
|
|
12
15
|
retryCondition: axiosRetry.isRetryableError,
|
|
13
|
-
|
|
16
|
+
shouldResetTimeout: true,
|
|
17
|
+
};
|
|
18
|
+
const SKIPPED_REST_CONFIG_KEYS = ['agent', 'retry'];
|
|
14
19
|
|
|
15
20
|
class RestClient {
|
|
16
21
|
constructor(options) {
|
|
@@ -24,6 +29,8 @@ class RestClient {
|
|
|
24
29
|
...this.getRestConfig(this.restClientConfig),
|
|
25
30
|
});
|
|
26
31
|
|
|
32
|
+
axiosRetry(this.axiosInstance, this.getRetryConfig());
|
|
33
|
+
|
|
27
34
|
if (this.restClientConfig?.debug) {
|
|
28
35
|
logger.addLogger(this.axiosInstance);
|
|
29
36
|
}
|
|
@@ -69,7 +76,7 @@ method: ${method}`,
|
|
|
69
76
|
if (!this.restClientConfig) return {};
|
|
70
77
|
|
|
71
78
|
const config = Object.keys(this.restClientConfig).reduce((acc, key) => {
|
|
72
|
-
if (key
|
|
79
|
+
if (!SKIPPED_REST_CONFIG_KEYS.includes(key)) {
|
|
73
80
|
acc[key] = this.restClientConfig[key];
|
|
74
81
|
}
|
|
75
82
|
return acc;
|
|
@@ -87,6 +94,26 @@ method: ${method}`,
|
|
|
87
94
|
return config;
|
|
88
95
|
}
|
|
89
96
|
|
|
97
|
+
getRetryConfig() {
|
|
98
|
+
const retryOption = this.restClientConfig?.retry;
|
|
99
|
+
|
|
100
|
+
if (typeof retryOption === 'number') {
|
|
101
|
+
return {
|
|
102
|
+
...DEFAULT_RETRY_CONFIG,
|
|
103
|
+
retries: retryOption,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (retryOption && typeof retryOption === 'object') {
|
|
108
|
+
return {
|
|
109
|
+
...DEFAULT_RETRY_CONFIG,
|
|
110
|
+
...retryOption,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return { ...DEFAULT_RETRY_CONFIG };
|
|
115
|
+
}
|
|
116
|
+
|
|
90
117
|
create(path, data, options = {}) {
|
|
91
118
|
return this.request('POST', this.buildPath(path), data, {
|
|
92
119
|
...options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reportportal/client-javascript",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.2",
|
|
4
4
|
"description": "ReportPortal client for Node.js",
|
|
5
5
|
"author": "ReportPortal.io",
|
|
6
6
|
"scripts": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"node": ">=14.x"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"axios": "^1.
|
|
29
|
-
"axios-retry": "^4.
|
|
28
|
+
"axios": "^1.12.2",
|
|
29
|
+
"axios-retry": "^4.5.0",
|
|
30
30
|
"glob": "^8.1.0",
|
|
31
31
|
"ini": "^2.0.0",
|
|
32
32
|
"uniqid": "^5.4.0",
|
package/statistics/constants.js
CHANGED
|
@@ -8,7 +8,8 @@ const PJSON_NAME = pjson.name;
|
|
|
8
8
|
const CLIENT_ID_KEY = 'client.id';
|
|
9
9
|
const RP_FOLDER = '.rp';
|
|
10
10
|
const RP_PROPERTIES_FILE = 'rp.properties';
|
|
11
|
-
const
|
|
11
|
+
const HOME_DIRECTORY = process.env.RP_CLIENT_JS_HOME || os.homedir();
|
|
12
|
+
const RP_FOLDER_PATH = path.join(HOME_DIRECTORY, RP_FOLDER);
|
|
12
13
|
const RP_PROPERTIES_FILE_PATH = path.join(RP_FOLDER_PATH, RP_PROPERTIES_FILE);
|
|
13
14
|
const CLIENT_INFO = Buffer.from(
|
|
14
15
|
'Ry1XUDU3UlNHOFhMOmVFazhPMGJ0UXZ5MmI2VXVRT19TOFE=',
|