Explorar el Código

fix: clear timeout after promise rejection (#24864)

Luke Parker hace 4 meses
padre
commit
9fbeafb63e
Se han modificado 1 ficheros con 1 adiciones y 2 borrados
  1. 1 2
      packages/opencode/src/util/timeout.ts

+ 1 - 2
packages/opencode/src/util/timeout.ts

@@ -1,9 +1,8 @@
 export function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
 export function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
   let timeout: NodeJS.Timeout
   let timeout: NodeJS.Timeout
   return Promise.race([
   return Promise.race([
-    promise.then((result) => {
+    promise.finally(() => {
       clearTimeout(timeout)
       clearTimeout(timeout)
-      return result
     }),
     }),
     new Promise<never>((_, reject) => {
     new Promise<never>((_, reject) => {
       timeout = setTimeout(() => {
       timeout = setTimeout(() => {