@@ -406,17 +406,6 @@ private protocol LambdaChannelHandlerDelegate {
406406 func connectionErrorHappened( _ error: any Error , channel: any Channel )
407407}
408408
409- struct UnsafeContext : @unchecked Sendable {
410- private let _context : ChannelHandlerContext
411- var context : ChannelHandlerContext {
412- self . _context. eventLoop. preconditionInEventLoop ( )
413- return _context
414- }
415- init ( _ context: ChannelHandlerContext ) {
416- self . _context = context
417- }
418- }
419-
420409private final class LambdaChannelHandler < Delegate: LambdaChannelHandlerDelegate > {
421410 let nextInvocationPath = Consts . invocationURLPrefix + Consts. getNextInvocationURLSuffix
422411
@@ -482,7 +471,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
482471 ( continuation: CheckedContinuation < Invocation , any Error > ) in
483472 self . state = . connected( context, . waitingForNextInvocation( continuation) )
484473
485- let unsafeContext = UnsafeContext ( context)
474+ let unsafeContext = NIOLoopBound ( context, eventLoop : context . eventLoop )
486475 context. eventLoop. execute { [ nextInvocationPath, defaultHeaders] in
487476 // Send next request. The function `sendNextRequest` requires `self` which is not
488477 // Sendable so just inlined the code instead
@@ -492,7 +481,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
492481 uri: nextInvocationPath,
493482 headers: defaultHeaders
494483 )
495- let context = unsafeContext. context
484+ let context = unsafeContext. value
496485 context. write ( Self . wrapOutboundOut ( . head( httpRequest) ) , promise: nil )
497486 context. write ( Self . wrapOutboundOut ( . end( nil ) ) , promise: nil )
498487 context. flush ( )
0 commit comments