gologin 2.1.26 → 2.1.27

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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ Combined changelog for GoLogin node.js SDK
5
5
  ## [2.1.26] 2025-07-02
6
6
 
7
7
 
8
+ ### New
9
+
10
+ * Added possibility to change proxy check timeout
11
+
12
+ ## [2.1.26] 2025-07-02
13
+
14
+
8
15
  ### Fixes
9
16
 
10
17
  * Socks 5 proxy passing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "2.1.26",
3
+ "version": "2.1.27",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "types": "./index.d.ts",
6
6
  "main": "./src/gologin.js",
package/src/gologin.js CHANGED
@@ -80,6 +80,8 @@ export class GoLogin {
80
80
  this.processKillTimeout = 1 * 1000;
81
81
  this.browserMajorVersion = 0;
82
82
  this.newProxyOrbbitaMajorVersion = 135;
83
+ this.proxyCheckTimeout = options.proxyCheckTimeout || 13 * 1000;
84
+ this.proxyCheckAttempts = options.proxyCheckAttempts || 3;
83
85
 
84
86
  if (process.env.DISABLE_TELEMETRY !== 'true') {
85
87
  Sentry.init({
@@ -738,9 +740,15 @@ export class GoLogin {
738
740
 
739
741
  const proxyUrl = `${proxy.mode}://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`;
740
742
  debug(`getTimeZone start ${TIMEZONE_URL}`, proxyUrl);
741
- data = await makeRequest(TIMEZONE_URL, { proxy: proxyUrl, timeout: 13 * 1000, maxAttempts: 3, method: 'GET' });
743
+
744
+ data = await makeRequest(TIMEZONE_URL, {
745
+ proxy: proxyUrl,
746
+ timeout: this.proxyCheckTimeout,
747
+ maxAttempts: this.proxyCheckAttempts,
748
+ method: 'GET',
749
+ });
742
750
  } else {
743
- data = await makeRequest(TIMEZONE_URL, { timeout: 13 * 1000, maxAttempts: 3, method: 'GET' });
751
+ data = await makeRequest(TIMEZONE_URL, { timeout: this.proxyCheckTimeout, maxAttempts: this.proxyCheckAttempts, method: 'GET' });
744
752
  }
745
753
 
746
754
  debug('getTimeZone finish', data);
@@ -810,7 +818,7 @@ export class GoLogin {
810
818
 
811
819
  await makeRequest(
812
820
  `${API_URL}/proxy/set_proxy_statuses`,
813
- { timeout: 13 * 1000, maxAttempts: 3, method: 'POST', json: statusBody },
821
+ { timeout: this.proxyCheckTimeout, maxAttempts: this.proxyCheckAttempts, method: 'POST', json: statusBody },
814
822
  { token: this.access_token, fallbackUrl: `${FALLBACK_API_URL}/proxy/set_proxy_statuses` },
815
823
  ).catch();
816
824
  }
package/src/utils/http.js CHANGED
@@ -3,8 +3,23 @@ import requests from 'requestretry';
3
3
 
4
4
  const TIMEZONE_URL = 'https://geo.myip.link';
5
5
 
6
+ const createTimeoutPromise = (timeoutMs) => new Promise((_, reject) => {
7
+ setTimeout(() => {
8
+ reject(new Error(`Request timeout after ${timeoutMs}ms`));
9
+ }, timeoutMs);
10
+ });
11
+
6
12
  const attemptRequest = async (requestUrl, options) => {
7
- const req = await requests(requestUrl, options);
13
+ const requestPromise = requests(requestUrl, options);
14
+
15
+ let req;
16
+ if (options.proxy) {
17
+ const timeoutPromise = createTimeoutPromise(options.timeout || 30000);
18
+ req = await Promise.race([requestPromise, timeoutPromise]);
19
+ } else {
20
+ req = await requestPromise;
21
+ }
22
+
8
23
  if (req.statusCode >= 400) {
9
24
  const error = new Error(req.body);
10
25
  error.statusCode = req.statusCode;
@@ -39,7 +54,7 @@ export const makeRequest = async (url, options, internalOptions) => {
39
54
  };
40
55
 
41
56
  export const checkSocksProxy = async (agent) => new Promise((resolve, reject) => {
42
- _get(TIMEZONE_URL, { agent, timeout: 10000 }, (res) => {
57
+ _get(TIMEZONE_URL, { agent, timeout: 8000 }, (res) => {
43
58
  let resultResponse = '';
44
59
  res.on('data', (data) => {
45
60
  resultResponse += data;