Skip to content

Commit 632daa4

Browse files
committed
fix(cli): clear HTTP timeout when response starts
- Clear timeout once response headers are received (callback invoked) - Prevents confusing 'timed out' errors when server is mid-response - Timeout now only applies to connection establishment phase - Updated error message to clarify 'no response' timeout
1 parent 8695941 commit 632daa4

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

cli/lib/checkup-api.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ async function postRpc<T>(params: {
217217
signal: controller.signal,
218218
},
219219
(res) => {
220+
// Response started (headers received) - clear the connection timeout.
221+
// Once the server starts responding, we let it complete rather than
222+
// timing out mid-response which would cause confusing errors.
223+
if (timeoutId) {
224+
clearTimeout(timeoutId);
225+
timeoutId = null;
226+
}
220227
let data = "";
221228
res.on("data", (chunk) => (data += chunk));
222229
res.on("end", () => {
@@ -246,11 +253,12 @@ async function postRpc<T>(params: {
246253
}
247254
);
248255

249-
// Set up timeout with both abort signal AND req.destroy() as backup
256+
// Set up connection timeout - applies until response headers are received.
257+
// Once response starts, timeout is cleared (see response callback above).
250258
timeoutId = setTimeout(() => {
251259
controller.abort();
252260
req.destroy(); // Backup: ensure request is terminated
253-
settledReject(new Error(`RPC ${rpcName} timed out after ${timeoutMs}ms`));
261+
settledReject(new Error(`RPC ${rpcName} timed out after ${timeoutMs}ms (no response)`));
254262
}, timeoutMs);
255263

256264
req.on("error", (err: Error) => {

0 commit comments

Comments
 (0)