|
|
@@ -1,5 +1,4 @@
|
|
|
import { Log } from "@/util/log"
|
|
|
-import { withTimeout } from "@/util/timeout"
|
|
|
|
|
|
export namespace State {
|
|
|
interface Entry {
|
|
|
@@ -8,7 +7,6 @@ export namespace State {
|
|
|
}
|
|
|
|
|
|
const log = Log.create({ service: "state" })
|
|
|
- const DISPOSE_TIMEOUT_MS = 10_000
|
|
|
const recordsByKey = new Map<string, Map<any, Entry>>()
|
|
|
|
|
|
export function create<S>(root: () => string, init: () => S, dispose?: (state: Awaited<S>) => Promise<void>) {
|
|
|
@@ -53,16 +51,11 @@ export namespace State {
|
|
|
|
|
|
const label = typeof init === "function" ? init.name : String(init)
|
|
|
|
|
|
- const task = withTimeout(
|
|
|
- Promise.resolve(entry.state).then((state) => entry.dispose!(state)),
|
|
|
- DISPOSE_TIMEOUT_MS,
|
|
|
- ).catch((error) => {
|
|
|
- if (error instanceof Error && error.message.includes("Operation timed out")) {
|
|
|
- log.warn("state disposal timed out", { key, init: label })
|
|
|
- return
|
|
|
- }
|
|
|
- log.error("Error while disposing state:", { error, key, init: label })
|
|
|
- })
|
|
|
+ const task = Promise.resolve(entry.state)
|
|
|
+ .then((state) => entry.dispose!(state))
|
|
|
+ .catch((error) => {
|
|
|
+ log.error("Error while disposing state:", { error, key, init: label })
|
|
|
+ })
|
|
|
|
|
|
tasks.push(task)
|
|
|
}
|