Closes, and does not come back while anything it started is still running.
Awaits every cleanup promise in closes, but never longer than graceMs. Resolves
whichever happens first: every close settles (Promise.allSettled absorbs rejections
so a single failing close cannot wedge the others), or the grace timer fires. Pending
closes keep running in the background after a timeout — the caller is expected to
process.exit() shortly after, which terminates them anyway.
What closeWithGrace gave up on, and a promise for those closes finally finishing.
-
names: string[]
The keys still pending when the grace expired. Empty when everything settled in time.
-
settled: Promise<void>
Settles when the abandoned closes do. Already settled when nothing was abandoned.
Default grace period for the cleanup race — generous enough for a healthy shutdown of
Playwright + HTTP server + Chrome pre-launch, well under the 60 s outer kill the test
runner imposes, and tuned around Firefox + Windows where browser.close() is known to
deadlock for the full 60 s.
Usage
import * as mod from "lib/utils/close-with-grace.ts";