@@ -11,6 +11,7 @@ import {
|
11 | 11 | describeFailoverError, |
12 | 12 | FailoverError, |
13 | 13 | isNonProviderRuntimeCoordinationError, |
| 14 | +isSignalTimeoutReason, |
14 | 15 | isTimeoutError, |
15 | 16 | resolveFailoverReasonFromError, |
16 | 17 | resolveFailoverStatus, |
@@ -1349,3 +1350,34 @@ describe("buildFailoverRemediationHint", () => {
|
1349 | 1350 | expect(buildFailoverRemediationHint("just a string")).toBeUndefined(); |
1350 | 1351 | }); |
1351 | 1352 | }); |
| 1353 | + |
| 1354 | +describe("isSignalTimeoutReason", () => { |
| 1355 | +it("returns false for plain AbortController.abort() DOMException (client disconnect)", () => { |
| 1356 | +// watchClientDisconnect calls abort() with no args, producing AbortError. |
| 1357 | +// This must not be classified as a run timeout (#90764). |
| 1358 | +const err = new DOMException("This operation was aborted", "AbortError"); |
| 1359 | +expect(isSignalTimeoutReason(err)).toBe(false); |
| 1360 | +}); |
| 1361 | + |
| 1362 | +it("returns false for AbortError whose message matches ABORT_TIMEOUT_RE", () => { |
| 1363 | +// Old isTimeoutError returned true here via ABORT_TIMEOUT_RE (/request.*aborted/i). |
| 1364 | +const err = Object.assign(new Error("request aborted"), { name: "AbortError" }); |
| 1365 | +expect(isSignalTimeoutReason(err)).toBe(false); |
| 1366 | +}); |
| 1367 | + |
| 1368 | +it("returns true for AbortSignal.timeout() DOMException", () => { |
| 1369 | +const err = new DOMException("signal timed out", "TimeoutError"); |
| 1370 | +expect(isSignalTimeoutReason(err)).toBe(true); |
| 1371 | +}); |
| 1372 | + |
| 1373 | +it("returns true for makeTimeoutAbortReason()-style Error", () => { |
| 1374 | +// makeTimeoutAbortReason() in attempt.ts: Error("request timed out", name="TimeoutError") |
| 1375 | +const err = Object.assign(new Error("request timed out"), { name: "TimeoutError" }); |
| 1376 | +expect(isSignalTimeoutReason(err)).toBe(true); |
| 1377 | +}); |
| 1378 | + |
| 1379 | +it("returns false for null and undefined", () => { |
| 1380 | +expect(isSignalTimeoutReason(null)).toBe(false); |
| 1381 | +expect(isSignalTimeoutReason(undefined)).toBe(false); |
| 1382 | +}); |
| 1383 | +}); |