@matterbridge/thread 3.9.3-dev-20260628-fa05360 → 3.9.3-dev-20260629-7c47082

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.
@@ -11,36 +11,18 @@ export function takeDockerVersionWarning() {
11
11
  async function httpsGetJson(url, headers, timeoutMs) {
12
12
  const https = await import('node:https');
13
13
  return new Promise((resolve, reject) => {
14
- let settled = false;
15
- let req;
16
- let timeoutId;
17
- const rejectOnce = (error) => {
18
- if (settled)
19
- return;
20
- settled = true;
21
- clearTimeout(timeoutId);
22
- reject(error);
23
- };
24
- const resolveOnce = (value) => {
25
- if (settled)
26
- return;
27
- settled = true;
28
- clearTimeout(timeoutId);
29
- resolve(value);
30
- };
31
- const timeoutError = new Error(`Request timed out after ${timeoutMs / 1000} seconds`);
32
- timeoutId = setTimeout(() => {
33
- req?.destroy?.(timeoutError);
34
- rejectOnce(timeoutError);
14
+ const controller = new AbortController();
15
+ const timeoutId = setTimeout(() => {
16
+ controller.abort();
17
+ reject(new Error(`Request timed out after ${timeoutMs / 1000} seconds`));
35
18
  }, timeoutMs).unref();
36
- req = https.get(url, { headers }, (res) => {
19
+ const req = https.get(url, { headers, signal: controller.signal }, (res) => {
37
20
  let data = '';
38
21
  const statusCode = res.statusCode ?? 0;
39
22
  if (statusCode >= 300 && statusCode < 400) {
40
23
  const locationHeader = Array.isArray(res.headers.location) ? res.headers.location[0] : res.headers.location;
41
24
  if (locationHeader) {
42
25
  clearTimeout(timeoutId);
43
- settled = true;
44
26
  res.resume();
45
27
  const redirectedUrl = new URL(locationHeader, url).toString();
46
28
  let redirectedHeaders = headers;
@@ -59,8 +41,9 @@ async function httpsGetJson(url, headers, timeoutMs) {
59
41
  }
60
42
  }
61
43
  if (statusCode < 200 || statusCode >= 300) {
44
+ clearTimeout(timeoutId);
62
45
  res.resume();
63
- rejectOnce(new Error(`Failed to fetch data. Status code: ${statusCode}`));
46
+ reject(new Error(`Failed to fetch data. Status code: ${statusCode}`));
64
47
  return;
65
48
  }
66
49
  res.on('data', (chunk) => {
@@ -68,15 +51,18 @@ async function httpsGetJson(url, headers, timeoutMs) {
68
51
  });
69
52
  res.on('end', () => {
70
53
  try {
71
- resolveOnce(JSON.parse(data));
54
+ clearTimeout(timeoutId);
55
+ resolve(JSON.parse(data));
72
56
  }
73
57
  catch (error) {
74
- rejectOnce(new Error(`Failed to parse response JSON: ${getErrorMessage(error)}`));
58
+ clearTimeout(timeoutId);
59
+ reject(new Error(`Failed to parse response JSON: ${getErrorMessage(error)}`));
75
60
  }
76
61
  });
77
62
  });
78
63
  req.on('error', (error) => {
79
- rejectOnce(new Error(`Request failed: ${getErrorMessage(error)}`));
64
+ clearTimeout(timeoutId);
65
+ reject(new Error(`Request failed: ${getErrorMessage(error)}`));
80
66
  });
81
67
  });
82
68
  }
@@ -124,6 +124,7 @@ export class WorkerWrapper {
124
124
  }
125
125
  try {
126
126
  parentPort.close();
127
+ process.exit(success ? 0 : 1);
127
128
  }
128
129
  catch (error) {
129
130
  this.log.error(`Worker ${this.name}:${threadId} failed to close parentPort: ${getErrorMessage(error)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/thread",
3
- "version": "3.9.3-dev-20260628-fa05360",
3
+ "version": "3.9.3-dev-20260629-7c47082",
4
4
  "description": "Matterbridge thread library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -69,8 +69,8 @@
69
69
  "CHANGELOG.md"
70
70
  ],
71
71
  "dependencies": {
72
- "@matterbridge/types": "3.9.3-dev-20260628-fa05360",
73
- "@matterbridge/utils": "3.9.3-dev-20260628-fa05360",
72
+ "@matterbridge/types": "3.9.3-dev-20260629-7c47082",
73
+ "@matterbridge/utils": "3.9.3-dev-20260629-7c47082",
74
74
  "@zip.js/zip.js": "2.8.26",
75
75
  "node-ansi-logger": "3.3.0"
76
76
  }