Rename withTimeout() to waitForResultWithTimeLimit()

The name withTimeout() gives the impression that it would limit the
execution of the promise to the given time bound. But that is not the
case: it is only the _waiting_ that is limited, and the promise would
keep running beyond the time bound.

This commit renames withTimeout() to waitForResultWithTimeLimit() so
that developers are more likely to understand the actual behavior of
this function.
This commit is contained in:
Chuan-kai Lin
2025-09-18 08:27:36 -07:00
parent b73659a4ff
commit 8185897cad
6 changed files with 36 additions and 24 deletions

View File

@@ -10,7 +10,11 @@ import { type CodeQL } from "./codeql";
import { type Config } from "./config-utils";
import { getCommitOid, getFileOidsUnderPath } from "./git-utils";
import { Logger, withGroupAsync } from "./logging";
import { isInTestMode, tryGetFolderBytes, withTimeout } from "./util";
import {
isInTestMode,
tryGetFolderBytes,
waitForResultWithTimeLimit,
} from "./util";
export enum OverlayDatabaseMode {
Overlay = "overlay",
@@ -268,7 +272,7 @@ export async function uploadOverlayBaseDatabaseToCache(
);
try {
const cacheId = await withTimeout(
const cacheId = await waitForResultWithTimeLimit(
MAX_CACHE_OPERATION_MS,
actionsCache.saveCache([dbLocation], cacheSaveKey),
() => {},
@@ -346,7 +350,7 @@ export async function downloadOverlayBaseDatabaseFromCache(
let databaseDownloadDurationMs = 0;
try {
const databaseDownloadStart = performance.now();
const foundKey = await withTimeout(
const foundKey = await waitForResultWithTimeLimit(
MAX_CACHE_OPERATION_MS,
actionsCache.restoreCache([dbLocation], cacheRestoreKeyPrefix),
() => {