@@ -365,16 +365,6 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
365
365
)
366
366
channel. closeFuture. whenComplete { result in
367
367
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
-
378
368
// close the channel
379
369
runtimeClient. channelClosed ( channel)
380
370
runtimeClient. connectionState = . disconnected
@@ -898,9 +888,16 @@ extension LambdaChannelHandler: ChannelInboundHandler {
898
888
func channelInactive( context: ChannelHandlerContext ) {
899
889
// fail any pending responses with last error or assume peer disconnected
900
890
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
+ }
902
900
self . state = . disconnected
903
- continuation. resume ( throwing: self . lastError ?? ChannelError . ioOnClosedChannel)
904
901
default :
905
902
break
906
903
}
0 commit comments