Skip to content

Commit acb92fc

Browse files
committed
chore: cleanup
1 parent c9bbea4 commit acb92fc

2 files changed

Lines changed: 7 additions & 17 deletions

File tree

packages/opencode/src/project/instance.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { State } from "./state"
55
import { iife } from "@/util/iife"
66
import { GlobalBus } from "@/bus/global"
77
import { Filesystem } from "@/util/filesystem"
8-
import { withTimeout } from "@/util/timeout"
98

109
interface Context {
1110
directory: string
@@ -15,8 +14,6 @@ interface Context {
1514
const context = Context.create<Context>("instance")
1615
const cache = new Map<string, Promise<Context>>()
1716

18-
const DISPOSE_TIMEOUT_MS = 10_000
19-
2017
const disposal = {
2118
all: undefined as Promise<void> | undefined,
2219
}
@@ -92,8 +89,8 @@ export const Instance = {
9289
for (const [key, value] of entries) {
9390
if (cache.get(key) !== value) continue
9491

95-
const ctx = await withTimeout(value, DISPOSE_TIMEOUT_MS).catch((error) => {
96-
Log.Default.warn("instance dispose timed out", { key, error })
92+
const ctx = await value.catch((error) => {
93+
Log.Default.warn("instance dispose failed", { key, error })
9794
return undefined
9895
})
9996

packages/opencode/src/project/state.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Log } from "@/util/log"
2-
import { withTimeout } from "@/util/timeout"
32

43
export namespace State {
54
interface Entry {
@@ -8,7 +7,6 @@ export namespace State {
87
}
98

109
const log = Log.create({ service: "state" })
11-
const DISPOSE_TIMEOUT_MS = 10_000
1210
const recordsByKey = new Map<string, Map<any, Entry>>()
1311

1412
export function create<S>(root: () => string, init: () => S, dispose?: (state: Awaited<S>) => Promise<void>) {
@@ -53,16 +51,11 @@ export namespace State {
5351

5452
const label = typeof init === "function" ? init.name : String(init)
5553

56-
const task = withTimeout(
57-
Promise.resolve(entry.state).then((state) => entry.dispose!(state)),
58-
DISPOSE_TIMEOUT_MS,
59-
).catch((error) => {
60-
if (error instanceof Error && error.message.includes("Operation timed out")) {
61-
log.warn("state disposal timed out", { key, init: label })
62-
return
63-
}
64-
log.error("Error while disposing state:", { error, key, init: label })
65-
})
54+
const task = Promise.resolve(entry.state)
55+
.then((state) => entry.dispose!(state))
56+
.catch((error) => {
57+
log.error("Error while disposing state:", { error, key, init: label })
58+
})
6659

6760
tasks.push(task)
6861
}

0 commit comments

Comments
 (0)