File tree Expand file tree Collapse file tree
packages/client-runtime/src/state Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -575,6 +575,7 @@ describe("EnvironmentThreads", () => {
575575 } ,
576576 } ) ;
577577 const state = yield * awaitThreadState ( h . observed , ( value ) => value . status === "live" ) ;
578+ expect ( yield * Ref . get ( h . removedThreads ) ) . toEqual ( [ THREAD_ID ] ) ;
578579 expect ( yield * Ref . get ( h . loaderCalls ) ) . toBe ( 1 ) ;
579580 expect ( Option . getOrThrow ( state . data ) ) . toEqual ( BASE_PROJECTION ) ;
580581 yield * TestClock . adjust ( "500 millis" ) ;
Original file line number Diff line number Diff line change @@ -241,8 +241,14 @@ export const makeEnvironmentThreadState = Effect.fn("EnvironmentThreadState.make
241241 const cached =
242242 retained === undefined
243243 ? yield * cache . loadThread ( environmentId , threadId ) . pipe (
244- // An oversized cache predates the size limit; a fresh bounded snapshot replaces it.
245- Effect . map ( Option . filter ( ( snapshot ) => isBoundedProjection ( snapshot . projection ) ) ) ,
244+ // An oversized cache predates the size limit. Drop it so no later open decodes it again.
245+ Effect . flatMap ( ( loaded ) =>
246+ Option . isSome ( loaded ) && ! isBoundedProjection ( loaded . value . projection )
247+ ? cache
248+ . removeThread ( environmentId , threadId )
249+ . pipe ( Effect . as ( Option . none < OrchestrationV2ThreadDetailSnapshot > ( ) ) )
250+ : Effect . succeed ( loaded ) ,
251+ ) ,
246252 Effect . catch ( ( error ) =>
247253 Effect . logWarning ( "Could not load cached thread." ) . pipe (
248254 Effect . annotateLogs ( {
You can’t perform that action at this time.
0 commit comments