From c1a0d9735a373934e013c5ee49dd3ba3c482f02f Mon Sep 17 00:00:00 2001 From: Raphael Mayr Date: Wed, 28 Jan 2026 23:05:10 +0100 Subject: [PATCH 1/4] Added timeout handling to avoid getting stuck when a website or service is not responding to a request --- src/spec-utils/httpRequest.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/spec-utils/httpRequest.ts b/src/spec-utils/httpRequest.ts index 43df09d78..d7582d003 100644 --- a/src/spec-utils/httpRequest.ts +++ b/src/spec-utils/httpRequest.ts @@ -40,6 +40,8 @@ export async function request(options: { type: string; url: string; headers: Rec res.on('data', chunk => chunks.push(chunk as Buffer)); res.on('end', () => resolve(Buffer.concat(chunks))); } + }).setTimeout(2000, () => { + req.end(); }); req.on('error', reject); if (options.data) { From a605b23b0b7b70e4307fa504001463705e3eab71 Mon Sep 17 00:00:00 2001 From: RaMaTHA <157792803+RaMaTHA@users.noreply.github.com> Date: Fri, 30 Jan 2026 10:32:47 +0100 Subject: [PATCH 2/4] Updated according to @abdurriq feedback --- src/spec-utils/httpRequest.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/spec-utils/httpRequest.ts b/src/spec-utils/httpRequest.ts index d7582d003..9191c151f 100644 --- a/src/spec-utils/httpRequest.ts +++ b/src/spec-utils/httpRequest.ts @@ -23,6 +23,7 @@ export async function request(options: { type: string; url: string; headers: Rec headers: options.headers, agent: new ProxyAgent(), secureContext, + timeout: 3000 }; const plainHTTP = parsed.protocol === 'http:' || parsed.hostname === 'localhost'; @@ -40,8 +41,9 @@ export async function request(options: { type: string; url: string; headers: Rec res.on('data', chunk => chunks.push(chunk as Buffer)); res.on('end', () => resolve(Buffer.concat(chunks))); } - }).setTimeout(2000, () => { - req.end(); + }); + req.on('timeout', () => { + req.destroy(); }); req.on('error', reject); if (options.data) { From a16897fa9da571156f9bc03af1f5ed25b686eefb Mon Sep 17 00:00:00 2001 From: RaMaTHA <157792803+RaMaTHA@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:36:05 +0100 Subject: [PATCH 3/4] Add a offline_mode flag. Increase the timeout add user feedback --- src/spec-utils/httpRequest.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/spec-utils/httpRequest.ts b/src/spec-utils/httpRequest.ts index 9191c151f..a2829e5b4 100644 --- a/src/spec-utils/httpRequest.ts +++ b/src/spec-utils/httpRequest.ts @@ -23,9 +23,15 @@ export async function request(options: { type: string; url: string; headers: Rec headers: options.headers, agent: new ProxyAgent(), secureContext, - timeout: 3000 + timeout: 60000, }; + const offline_mode: boolean = (process.env.OFFLINE_MODE ?? 'false') === 'true'; + if (offline_mode) { + output.write('Offline mode enabled, skipping request', LogLevel.Warning); + return; + } + const plainHTTP = parsed.protocol === 'http:' || parsed.hostname === 'localhost'; if (plainHTTP) { output.write('Sending as plain HTTP request', LogLevel.Warning); @@ -43,6 +49,7 @@ export async function request(options: { type: string; url: string; headers: Rec } }); req.on('timeout', () => { + output.write('Request timed out, aborting', LogLevel.Warning); req.destroy(); }); req.on('error', reject); From 84db8e46390c01669320b2e0ce7088ee9956bf72 Mon Sep 17 00:00:00 2001 From: RaMaTHA <157792803+RaMaTHA@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:05:43 +0100 Subject: [PATCH 4/4] Remove the timeout handling. Add error throw with feedback information. --- src/spec-utils/httpRequest.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/spec-utils/httpRequest.ts b/src/spec-utils/httpRequest.ts index a2829e5b4..b5cf3a17c 100644 --- a/src/spec-utils/httpRequest.ts +++ b/src/spec-utils/httpRequest.ts @@ -23,13 +23,13 @@ export async function request(options: { type: string; url: string; headers: Rec headers: options.headers, agent: new ProxyAgent(), secureContext, - timeout: 60000, }; const offline_mode: boolean = (process.env.OFFLINE_MODE ?? 'false') === 'true'; if (offline_mode) { - output.write('Offline mode enabled, skipping request', LogLevel.Warning); - return; + // Use the exception handling as a signal to skip the request + const err = `Offline mode enabled. Aboring request.`; + throw new Error(err); } const plainHTTP = parsed.protocol === 'http:' || parsed.hostname === 'localhost'; @@ -48,10 +48,6 @@ export async function request(options: { type: string; url: string; headers: Rec res.on('end', () => resolve(Buffer.concat(chunks))); } }); - req.on('timeout', () => { - output.write('Request timed out, aborting', LogLevel.Warning); - req.destroy(); - }); req.on('error', reject); if (options.data) { req.write(options.data);