File tree Expand file tree Collapse file tree
packages/opencode/src/project Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { State } from "./state"
55import { iife } from "@/util/iife"
66import { GlobalBus } from "@/bus/global"
77import { Filesystem } from "@/util/filesystem"
8- import { withTimeout } from "@/util/timeout"
98
109interface Context {
1110 directory : string
@@ -15,8 +14,6 @@ interface Context {
1514const context = Context . create < Context > ( "instance" )
1615const cache = new Map < string , Promise < Context > > ( )
1716
18- const DISPOSE_TIMEOUT_MS = 10_000
19-
2017const 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
Original file line number Diff line number Diff line change 11import { Log } from "@/util/log"
2- import { withTimeout } from "@/util/timeout"
32
43export 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 }
You can’t perform that action at this time.
0 commit comments