Skip to content
← Public packages

@kentcdodds/codemod-runner

Run codemods over your own saved packages: scan, dry-run with real publish checks and diffs, apply, and revert.

src/time-budget.ts

24 lines · 800 B · TypeScript
/** Stop starting new packages once a step has been running this long. */
export const stepTimeBudgetMs = 40_000

/**
 * Do not start another package when elapsed + the last package duration
 * would land near the ~90s sandbox timeout.
 */
export const stepHardCeilingMs = 75_000

/**
 * After at least one package has finished, stop before starting the next
 * when the step budget is spent or the last package's duration would push
 * the call past the sandbox ceiling.
 */
export function shouldStopBeforeNextPackage(input: {
	elapsedMs: number
	completedCount: number
	lastPackageMs: number
}): boolean {
	if (input.completedCount === 0) return false
	if (input.elapsedMs > stepTimeBudgetMs) return true
	if (input.elapsedMs + input.lastPackageMs > stepHardCeilingMs) return true
	return false
}