clever-tools 5.0.1 → 5.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clever-tools",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "Command Line Interface for Clever Cloud.",
5
5
  "keywords": [
6
6
  "cli",
@@ -22,6 +22,16 @@ const THROTTLE_ELEMENTS = 2000;
22
22
 
23
23
  const THROTTLE_PER_IN_MILLISECONDS = 100;
24
24
 
25
+ // Same policy as `clever logs` (src/models/log.js): a redeployment of the API cuts the stream
26
+ // without an END_OF_STREAM, which the client only notices through its heartbeat watchdog.
27
+ // Without retry that ends the command; with it the stream reconnects and resumes from the
28
+ // last event id.
29
+ const RETRY_CONFIGURATION = {
30
+ enabled: true,
31
+ initRetryTimeout: 3000,
32
+ maxRetryCount: 10,
33
+ };
34
+
25
35
  const CITY_MAX_LENGTH = 20;
26
36
 
27
37
  /**
@@ -111,6 +121,8 @@ export const accesslogsCommand = defineCommand({
111
121
  tokens,
112
122
  ownerId,
113
123
  appId,
124
+ connectionTimeout: 10_000,
125
+ retryConfiguration: RETRY_CONFIGURATION,
114
126
  since,
115
127
  until,
116
128
  throttleElements: THROTTLE_ELEMENTS,
@@ -4,9 +4,15 @@
4
4
  export class JsonArray {
5
5
  constructor() {
6
6
  this._isFirst = true;
7
+ this._isOpen = false;
7
8
  }
8
9
 
10
+ // Streams emit "open" again after each reconnection, the array must only be opened once
9
11
  open() {
12
+ if (this._isOpen) {
13
+ return;
14
+ }
15
+ this._isOpen = true;
10
16
  process.stdout.write('[\n');
11
17
  }
12
18
 
@@ -20,6 +26,10 @@ export class JsonArray {
20
26
  }
21
27
 
22
28
  close() {
29
+ if (!this._isOpen) {
30
+ return;
31
+ }
32
+ this._isOpen = false;
23
33
  process.stdout.write('\n]');
24
34
  }
25
35
  }