@@ -410,17 +410,6 @@ private protocol LambdaChannelHandlerDelegate {
410410 func connectionErrorHappened( _ error: any Error , channel: any Channel )
411411}
412412
413- struct UnsafeContext : @unchecked Sendable {
414- private let _context : ChannelHandlerContext
415- var context : ChannelHandlerContext {
416- self . _context. eventLoop. preconditionInEventLoop ( )
417- return _context
418- }
419- init ( _ context: ChannelHandlerContext ) {
420- self . _context = context
421- }
422- }
423-
424413private final class LambdaChannelHandler < Delegate: LambdaChannelHandlerDelegate > {
425414 let nextInvocationPath = Consts . invocationURLPrefix + Consts. getNextInvocationURLSuffix
426415
@@ -486,7 +475,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
486475 ( continuation: CheckedContinuation < Invocation , any Error > ) in
487476 self . state = . connected( context, . waitingForNextInvocation( continuation) )
488477
489- let unsafeContext = UnsafeContext ( context)
478+ let unsafeContext = NIOLoopBound ( context, eventLoop : context . eventLoop )
490479 context. eventLoop. execute { [ nextInvocationPath, defaultHeaders] in
491480 // Send next request. The function `sendNextRequest` requires `self` which is not
492481 // Sendable so just inlined the code instead
@@ -496,7 +485,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
496485 uri: nextInvocationPath,
497486 headers: defaultHeaders
498487 )
499- let context = unsafeContext. context
488+ let context = unsafeContext. value
500489 context. write ( Self . wrapOutboundOut ( . head( httpRequest) ) , promise: nil )
501490 context. write ( Self . wrapOutboundOut ( . end( nil ) ) , promise: nil )
502491 context. flush ( )
0 commit comments