Interrupt live traffic retry delays on stop
Build and Deploy Gateway / build-and-push (push) Successful in 1m58s
Build and Deploy Gateway / deploy (push) Successful in 19s

This commit is contained in:
2026-08-31 05:34:56 +03:00
parent bdf3f22b12
commit 79e00a2390
4 changed files with 53 additions and 21 deletions
+13 -4
View File
@@ -639,10 +639,17 @@ function defaultClientFactory(port: number): NativeTrafficClient {
}));
}
function delay(milliseconds: number) {
function delay(milliseconds: number, signal: AbortSignal) {
return new Promise<void>((resolve) => {
const timer = setTimeout(resolve, milliseconds);
const finish = () => {
clearTimeout(timer);
signal.removeEventListener('abort', finish);
resolve();
};
const timer = setTimeout(finish, milliseconds);
timer.unref();
signal.addEventListener('abort', finish, { once: true });
if (signal.aborted) finish();
});
}
@@ -660,6 +667,7 @@ export function createLiveTrafficService({
const ledger = createLiveTrafficLedger({ enabled, gateway, resolveOrigin });
if (!enabled && unavailableError) ledger.markUnavailable(unavailableError);
let stopped = false;
const stopController = new AbortController();
let controller: AbortController | null = null;
let running: Promise<void> | null = null;
let failedProjection: NativeTrafficProjectionBatch | null = null;
@@ -742,7 +750,7 @@ export function createLiveTrafficService({
while (!stopped) {
if (!isRuntimeRunning()) {
ledger.markStopped();
await delay(RETRY_MS);
await delay(RETRY_MS, stopController.signal);
continue;
}
controller = new AbortController();
@@ -756,7 +764,7 @@ export function createLiveTrafficService({
} finally {
controller = null;
}
if (!stopped) await delay(RETRY_MS);
if (!stopped) await delay(RETRY_MS, stopController.signal);
}
};
@@ -767,6 +775,7 @@ export function createLiveTrafficService({
},
async stop() {
stopped = true;
stopController.abort();
controller?.abort();
await running;
},
+3 -3
View File
@@ -1,7 +1,7 @@
export const HARBOR_VERSIONS = Object.freeze({
macClient: '0.34.0',
gatewayClient: '0.36.0',
gatewayBackend: '0.36.0',
macClient: '0.34.1',
gatewayClient: '0.36.1',
gatewayBackend: '0.36.1',
});
export interface ParsedVersion {