browserstack-cypress-cli 1.31.3 → 1.31.4
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/bin/testObservability/helper/cleanupQueueSync.js +13 -0
- package/bin/testObservability/helper/constants.js +2 -0
- package/bin/testObservability/helper/helper.js +3 -2
- package/bin/testObservability/helper/requestQueueHandler.js +15 -2
- package/bin/testObservability/plugin/ipcServer.js +4 -0
- package/bin/testObservability/reporter/index.js +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sending all the remaining queues for synchronous manner
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const RequestQueueHandler = require('./requestQueueHandler');
|
|
6
|
+
|
|
7
|
+
const shutdown = async () => {
|
|
8
|
+
const requestHandler = new RequestQueueHandler();
|
|
9
|
+
requestHandler.queue = require(process.argv[2].trim());
|
|
10
|
+
await requestHandler.shutdown();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
shutdown();
|
|
@@ -32,3 +32,5 @@ exports.OBSERVABILITY_ENV_VARS = [
|
|
|
32
32
|
exports.TEST_OBSERVABILITY_REPORTER = 'browserstack-cypress-cli/bin/testObservability/reporter';
|
|
33
33
|
|
|
34
34
|
exports.TEST_OBSERVABILITY_REPORTER_LOCAL = path.join(__dirname, '..', 'reporter');
|
|
35
|
+
|
|
36
|
+
exports.PENDING_QUEUES_FILE = `pending_queues_${process.pid}.json`;
|
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const http = require('http');
|
|
4
4
|
const https = require('https');
|
|
5
|
-
const request = require('
|
|
5
|
+
const request = require('requestretry');
|
|
6
6
|
const { v4: uuidv4 } = require('uuid');
|
|
7
7
|
const os = require('os');
|
|
8
8
|
const { promisify } = require('util');
|
|
@@ -114,7 +114,8 @@ const nodeRequest = (type, url, data, config) => {
|
|
|
114
114
|
url: `${API_URL}/${url}`,
|
|
115
115
|
body: data,
|
|
116
116
|
json: config.headers['Content-Type'] === 'application/json',
|
|
117
|
-
agent: this.httpsKeepAliveAgent
|
|
117
|
+
agent: this.httpsKeepAliveAgent,
|
|
118
|
+
maxAttempts: 2
|
|
118
119
|
}};
|
|
119
120
|
|
|
120
121
|
if(url === exports.requestQueueHandler.screenshotEventUrl) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const cp = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const { BATCH_SIZE, BATCH_INTERVAL, PENDING_QUEUES_FILE } = require('./constants');
|
|
6
|
+
const { batchAndPostEvents } = require('./helper');
|
|
3
7
|
|
|
4
8
|
class RequestQueueHandler {
|
|
5
9
|
constructor() {
|
|
@@ -48,6 +52,15 @@ class RequestQueueHandler {
|
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|
|
55
|
+
shutdownSync = () => {
|
|
56
|
+
this.removeEventBatchPolling('REMOVING');
|
|
57
|
+
|
|
58
|
+
fs.writeFileSync(path.join(__dirname, PENDING_QUEUES_FILE), JSON.stringify(this.queue));
|
|
59
|
+
this.queue = [];
|
|
60
|
+
cp.spawnSync('node', [path.join(__dirname, 'cleanupQueueSync.js'), path.join(__dirname, PENDING_QUEUES_FILE)], {stdio: 'inherit'});
|
|
61
|
+
fs.unlinkSync(path.join(__dirname, PENDING_QUEUES_FILE));
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
shutdown = async () => {
|
|
52
65
|
this.removeEventBatchPolling('REMOVING');
|
|
53
66
|
while(this.queue.length > 0) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const ipc = require('node-ipc');
|
|
2
2
|
const { consoleHolder } = require('../helper/constants');
|
|
3
|
+
const { requestQueueHandler } = require('../helper/helper');
|
|
3
4
|
|
|
4
5
|
exports.startIPCServer = (subscribeServerEvents, unsubscribeServerEvents) => {
|
|
5
6
|
if (ipc.server) {
|
|
@@ -26,6 +27,9 @@ exports.startIPCServer = (subscribeServerEvents, unsubscribeServerEvents) => {
|
|
|
26
27
|
process.on('exit', () => {
|
|
27
28
|
unsubscribeServerEvents(ipc.server);
|
|
28
29
|
ipc.server.stop();
|
|
30
|
+
// Cleaning up all remaining event in request queue handler. Any synchronous operations
|
|
31
|
+
// on exit handler will block the process
|
|
32
|
+
requestQueueHandler.shutdownSync();
|
|
29
33
|
});
|
|
30
34
|
|
|
31
35
|
});
|