@@ -61,47 +61,42 @@ export const make = Effect.gen(function* () {
6161 const id = ++ nextId ;
6262 let released = false ;
6363 const initialize : SearchOperation = { method : "initialize" , cwd, variant } ;
64- const run = Effect . fn ( "WorkspaceSearchHost.request" ) (
65- function * ( operation : SearchOperation ) {
66- yield * Effect . annotateCurrentSpan ( { cwd, variant, operation : operation . method } ) ;
67- if ( closed || released )
68- return yield * new WorkspaceSearchProcessFailed ( {
69- cause : new Error ( "Workspace search index is closed." ) ,
70- } ) ;
71- activeIndex = id ;
72- return yield * Effect . gen ( function * ( ) {
73- const active = yield * Effect . gen ( function * ( ) {
74- if ( current ) return current ;
75- const process = yield * startSearchProcess ( ) ;
76- current = { process, indexes : new Set < number > ( ) } ;
77- return current ;
78- } ) . pipe ( Effect . uninterruptible ) ;
79- if ( ! active . indexes . has ( id ) ) {
80- yield * active . process . request ( { id, operation : initialize } ) ;
81- active . indexes . add ( id ) ;
82- }
83- return operation . method === "initialize"
84- ? null
85- : yield * active . process . request ( { id, operation } ) ;
86- } ) . pipe (
87- Effect . onError ( ( cause ) =>
88- cause . reasons . length > 0 &&
89- cause . reasons . every (
90- ( reason ) => Cause . isFailReason ( reason ) && isRecoverable ( reason . error ) ,
91- )
92- ? Effect . void
93- : stop ( ) ,
94- ) ,
95- Effect . ensuring (
96- Effect . sync ( ( ) => {
97- activeIndex = undefined ;
98- } ) ,
99- ) ,
100- ) ;
101- } ,
102- semaphore . withPermits ( 1 ) ,
103- Effect . timeout ( "20 seconds" ) ,
104- ) ;
64+ const run = Effect . fn ( "WorkspaceSearchHost.request" ) ( function * ( operation : SearchOperation ) {
65+ yield * Effect . annotateCurrentSpan ( { cwd, variant, operation : operation . method } ) ;
66+ if ( closed || released )
67+ return yield * new WorkspaceSearchProcessFailed ( {
68+ cause : new Error ( "Workspace search index is closed." ) ,
69+ } ) ;
70+ activeIndex = id ;
71+ return yield * Effect . gen ( function * ( ) {
72+ const active = yield * Effect . gen ( function * ( ) {
73+ if ( current ) return current ;
74+ const process = yield * startSearchProcess ( ) ;
75+ current = { process, indexes : new Set < number > ( ) } ;
76+ return current ;
77+ } ) . pipe ( Effect . uninterruptible ) ;
78+ if ( ! active . indexes . has ( id ) ) {
79+ yield * active . process . request ( { id, operation : initialize } ) ;
80+ active . indexes . add ( id ) ;
81+ }
82+ return operation . method === "initialize"
83+ ? null
84+ : yield * active . process . request ( { id, operation } ) ;
85+ } ) . pipe (
86+ Effect . timeout ( "20 seconds" ) ,
87+ Effect . onError ( ( cause ) =>
88+ cause . reasons . length > 0 &&
89+ cause . reasons . every ( ( reason ) => Cause . isFailReason ( reason ) && isRecoverable ( reason . error ) )
90+ ? Effect . void
91+ : stop ( ) ,
92+ ) ,
93+ Effect . ensuring (
94+ Effect . sync ( ( ) => {
95+ activeIndex = undefined ;
96+ } ) ,
97+ ) ,
98+ ) ;
99+ } , semaphore . withPermits ( 1 ) ) ;
105100
106101 yield * Effect . addFinalizer ( ( ) =>
107102 Effect . gen ( function * ( ) {
0 commit comments