From 460ce9829a0179f00df65deea1b59fe9f040f4a3 Mon Sep 17 00:00:00 2001 From: William Storey Date: Tue, 21 Apr 2026 09:26:50 -0700 Subject: [PATCH] Fix flaky WebServiceClient error-handling tests The `handles timeouts` test registers a nock interceptor with a 100ms connection delay while the client's own timeout is 10ms. The client aborts at 10ms, but nock's pending setTimeout for the delayed reply keeps ticking and could fire during a later test, producing a spurious `InterceptorError: ... the request has already been handled`. Call `nock.abortPendingRequests()` alongside `cleanAll()` in afterEach so that leaked timer can't bleed into the next test. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/webServiceClient.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/webServiceClient.spec.ts b/src/webServiceClient.spec.ts index 896b185e..96ef925f 100644 --- a/src/webServiceClient.spec.ts +++ b/src/webServiceClient.spec.ts @@ -902,6 +902,12 @@ describe('WebServiceClient', () => { describe('error handling', () => { afterEach(() => { + // `handles timeouts` below uses `.delayConnection(100)` with a 10ms + // client timeout. The client aborts at 10ms, but nock's pending reply + // timer keeps ticking and can fire in a later test — producing a + // spurious `InterceptorError: ... the request has already been + // handled`. Abort those timers so they can't bleed across tests. + nock.abortPendingRequests(); nock.cleanAll(); });