Skip to content

Commit 3cf72af

Browse files
committed
fix: timeoutSignal is lost after being overriden with controller.signal
1 parent d02aeaf commit 3cf72af

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/watch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { KubeConfig } from './config.js';
66
export class Watch {
77
public static SERVER_SIDE_CLOSE: object = { error: 'Connection closed on server' };
88
public config: KubeConfig;
9-
private defaultRequestTimeoutMs: number = 30000;
9+
private requestTimeoutMs: number = 30000;
1010

1111
public constructor(config: KubeConfig) {
1212
this.config = config;
@@ -40,7 +40,7 @@ export class Watch {
4040
const requestInit = await this.config.applyToFetchOptions({});
4141

4242
const controller = new AbortController();
43-
const timeoutSignal = AbortSignal.timeout(this.defaultRequestTimeoutMs);
43+
const timeoutSignal = AbortSignal.timeout(this.requestTimeoutMs);
4444
requestInit.signal = AbortSignal.any([controller.signal, timeoutSignal]);
4545
requestInit.method = 'GET';
4646

src/watch_test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,9 @@ describe('Watch', () => {
457457
// Don't respond - simulate a hanging server
458458
});
459459
const watch = new Watch(kc);
460-
// Hack around type system to make the default timeout shorter.
461-
(watch as any).timeoutMs = 100;
460+
461+
// NOTE: Hack around the type system to make the timeout shorter
462+
(watch as any).requestTimeoutMs = 100;
462463

463464
let doneCalled = false;
464465
let doneErr: any;

0 commit comments

Comments
 (0)