Skip to content

Commit 9fbeafb

Browse files
authored
fix: clear timeout after promise rejection (#24864)
1 parent 91bd295 commit 9fbeafb

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

packages/opencode/src/util/timeout.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
export function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
22
let timeout: NodeJS.Timeout
33
return Promise.race([
4-
promise.then((result) => {
4+
promise.finally(() => {
55
clearTimeout(timeout)
6-
return result
76
}),
87
new Promise<never>((_, reject) => {
98
timeout = setTimeout(() => {

0 commit comments

Comments
 (0)