@@ -365,16 +365,6 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
365365 )
366366 channel. closeFuture. whenComplete { result in
367367 self . assumeIsolated { runtimeClient in
368-
369- // resume any pending continuation on the handler
370- if case . connected( _, let handler) = runtimeClient. connectionState {
371- if case . connected( _, let lambdaState) = handler. state {
372- if case . waitingForNextInvocation( let continuation) = lambdaState {
373- continuation. resume ( throwing: LambdaRuntimeError ( code: . connectionToControlPlaneLost) )
374- }
375- }
376- }
377-
378368 // close the channel
379369 runtimeClient. channelClosed ( channel)
380370 runtimeClient. connectionState = . disconnected
@@ -898,9 +888,16 @@ extension LambdaChannelHandler: ChannelInboundHandler {
898888 func channelInactive( context: ChannelHandlerContext ) {
899889 // fail any pending responses with last error or assume peer disconnected
900890 switch self . state {
901- case . connected( _, . waitingForNextInvocation( let continuation) ) :
891+ case . connected( _, let lambdaState) :
892+ switch lambdaState {
893+ case . waitingForNextInvocation( let continuation) :
894+ continuation. resume ( throwing: self . lastError ?? ChannelError . ioOnClosedChannel)
895+ case . sentResponse( let continuation) :
896+ continuation. resume ( throwing: self . lastError ?? ChannelError . ioOnClosedChannel)
897+ case . idle, . sendingResponse, . waitingForResponse:
898+ break
899+ }
902900 self . state = . disconnected
903- continuation. resume ( throwing: self . lastError ?? ChannelError . ioOnClosedChannel)
904901 default :
905902 break
906903 }
0 commit comments