Skip to content

Commit 63585db

Browse files
authored
refactor: replace Bun.sleep with node:timers/promises sleep (#18301)
1 parent bd44489 commit 63585db

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/opencode/src/cli/cmd/tui/component/dialog-workspace-list.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useToast } from "../ui/toast"
99
import { useKeybind } from "../context/keybind"
1010
import { DialogSessionList } from "./workspace/dialog-session-list"
1111
import { createOpencodeClient } from "@opencode-ai/sdk/v2"
12+
import { setTimeout as sleep } from "node:timers/promises"
1213

1314
async function openWorkspace(input: {
1415
dialog: ReturnType<typeof useDialog>
@@ -56,7 +57,7 @@ async function openWorkspace(input: {
5657
return
5758
}
5859
if (result.response.status >= 500 && result.response.status < 600) {
59-
await Bun.sleep(1000)
60+
await sleep(1000)
6061
continue
6162
}
6263
if (!result.data) {

packages/opencode/src/control-plane/workspace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import z from "zod"
2+
import { setTimeout as sleep } from "node:timers/promises"
23
import { fn } from "@/util/fn"
34
import { Database, eq } from "@/storage/db"
45
import { Project } from "@/project/project"
@@ -117,7 +118,7 @@ export namespace Workspace {
117118
const adaptor = await getAdaptor(space.type)
118119
const res = await adaptor.fetch(space, "/event", { method: "GET", signal: stop }).catch(() => undefined)
119120
if (!res || !res.ok || !res.body) {
120-
await Bun.sleep(1000)
121+
await sleep(1000)
121122
continue
122123
}
123124
await parseSSE(res.body, stop, (event) => {
@@ -127,7 +128,7 @@ export namespace Workspace {
127128
})
128129
})
129130
// Wait 250ms and retry if SSE connection fails
130-
await Bun.sleep(250)
131+
await sleep(250)
131132
}
132133
}
133134

0 commit comments

Comments
 (0)