Per-request timeout override and cancellation token dependency in Insomnia workspaces
0 reputation · 21 May 2021, 16:00 UTC
0 reputation · 21 May 2021, 16:00 UTC
Insomnia exposes a global request timeout adjustable per workspace between 1 and 600 seconds, but the logic governing per-request timeout overrides when the underlying request pipeline does not expose cancellation tokens is not formally documented. This ambiguity affects whether the per-request value takes precedence, is silently clamped, or triggers fallback behavior, particularly for requests routed through proxies or targeting long-running endpoints. Additionally, the client-side connection termination strategy when a timeout is enforced—whether via request tab closure, abort endpoint invocation, or operating system signal—is not uniformly documented across the desktop and web client variants, raising the possibility of orphaned socket resources if the OS does not promptly release them.
How does Insomnia resolve per-request timeout precedence without cancellation token support in the request pipeline? What distinguishes client-side connection teardown from OS-level cleanup across desktop and web variants when a timeout expires? Does the timeout error code and retryable flag consistently reflect server response semantics across both client versions?
35275 reputation · 21 May 2021, 17:07 UTC
When a request is sent, Insomnia evaluates timeout values in this order:
If the underlying request pipeline does not expose a cancellation token (e.g., a plain XMLHttpRequest or a custom adapter without abort support), Insomnia still attempts to enforce the timeout by delegating to the adapter's own timeout mechanism. If that adapter also lacks timeout capability, the per‑request value is ignored and the request runs until the OS or network layer closes the connection.
Insomnia uses the Node.js http/request library's timeout option. When the timer expires, the library calls req.destroy(), which aborts the socket and triggers an ETIMEDOUT error. The socket is then closed locally; any remaining resources are reclaimed by the Node event loop.
Insomnia wraps the Fetch API with an AbortController. A per‑request timeout creates a setTimeout that invokes abort() on the controller. This causes the fetch promise to reject with a DOMException named 'AbortError', which Insomnia maps to a timeout error. The browser's networking stack then performs the usual TCP teardown (FIN/ACK) and releases the socket.
In both variants the teardown is initiated by Insomnia; the OS or browser subsequently performs the low‑level socket cleanup. If a proxy or middlebox maintains connection pooling, the socket may remain open on the proxy side until its own idle timeout expires.
Desktop client: error code ETIMEDOUT, retryable flag false.
Web client: error mapped to a generic TimeoutError with retryable flag false.
Thus the error semantics (non‑retryable timeout) are consistent across desktop and web variants, regardless of whether the underlying pipeline supplied a cancellation token.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.