Skip to content

Fatal error: 'try!' expression unexpectedly raised an error: NIOCore.ChannelPipelineError.notFound #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shenfu1991 opened this issue Mar 12, 2023 · 1 comment · Fixed by #671

Comments

@shenfu1991
Copy link

Vapor version : 4.69.2
OS: ubuntu 20.04

AsyncHTTPClient/HTTPConnectionPool+Factory.swift:366: Fatal error: 'try!' expression unexpectedly raised an error: NIOCore.ChannelPipelineError.notFound
Current stack trace:
0    libswiftCore.so                    0x00007fac387e4930 _swift_stdlib_reportFatalErrorInFile + 112
1    libswiftCore.so                    0x00007fac384af8ec  + 1444076
2    libswiftCore.so                    0x00007fac384af708  + 1443592
3    libswiftCore.so                    0x00007fac384ae1f0 _assertionFailure(_:_:file:line:flags:) + 419
4    libswiftCore.so                    0x00007fac385030b0 swift_unexpectedError + 748
5    dx_3                               0x00005576644b348c  + 3847308
6    dx_3                               0x0000557664d92712  + 13149970
7    dx_3                               0x0000557664d92e63  + 13151843
8    dx_3                               0x0000557664d95ecc  + 13164236
9    dx_3                               0x00005576650a5088  + 16371848
10   dx_3                               0x00005576650a7ec0  + 16383680
11   dx_3                               0x000055766509de52  + 16342610
12   dx_3                               0x00005576650a33fc  + 16364540
13   dx_3                               0x0000557665063a37  + 16103991
14   dx_3                               0x000055766506411d  + 16105757
15   dx_3                               0x00005576650698fc  + 16128252
16   dx_3                               0x00005576650dca9f  + 16599711
17   dx_3                               0x00005576650df5d2  + 16610770
18   dx_3                               0x00005576650df6d9  + 16611033
19   libpthread.so.0                    0x00007fac38abb609  + 34313
20   libc.so.6                          0x00007fac380220f0 clone + 67
Received signal 4. Backtrace:
0x5576648215bf, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /root/dx_3/x-bot/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
0x5576648218e9, closure #1 (Swift.Int32) -> () in static Backtrace.Backtrace.install(signals: Swift.Array) -> () at /root/dx_3/x-bot/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:80
0x557664821908, @objc closure #1 (Swift.Int32) -> () in static Backtrace.Backtrace.install(signals: Swift.Array) -> () at /root/dx_3/x-bot/:0
0x7fac38ac741f
0x7fac384ae39f
0x7fac3850339b
0x5576644b348b, closure #2 @Sendable (NIOCore.Channel) -> NIOCore.EventLoopFuture<(NIOCore.Channel, Swift.Optional)> in AsyncHTTPClient.HTTPConnectionPool.ConnectionFactory.(makeTLSChannel in _AE48F78949F7DE5CB0E8AD63B3EC3A4B)(requester: A, connectionID: Swift.Int, deadline: NIOCore.NIODeadline, eventLoop: NIOCore.EventLoop, logger: Logging.Logger) -> NIOCore.EventLoopFuture<(NIOCore.Channel, Swift.Optional)> at /root/dx_3/x-bot/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift:366
0x557664d92711, closure #1 @Sendable () -> NIOCore.CallbackList in NIOCore.EventLoopFuture._flatMap(@Sendable (A) -> NIOCore.EventLoopFuture) -> NIOCore.EventLoopFuture at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:525
0x557664d92e62, NIOCore.EventLoopFuture._addCallback(@Sendable () -> NIOCore.CallbackList) -> NIOCore.CallbackList at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:935
0x557664d95ecb, closure #1 @Sendable () -> () in NIOCore.EventLoopFuture._internalWhenComplete(@Sendable () -> NIOCore.CallbackList) -> () at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:962
0x5576650a5087, closure #4 () -> () in NIOPosix.SelectableEventLoop.run() throws -> () at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:533
0x5576650a7ebf, partial apply forwarder for closure #4 () -> () in NIOPosix.SelectableEventLoop.run() throws -> () at /root/dx_3/x-bot/:0
0x55766509de51, NIOPosix.withAutoReleasePool(() throws -> A) throws -> A at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:29
0x5576650a33fb, NIOPosix.SelectableEventLoop.run() throws -> () at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:532
0x557665063a36, static NIOPosix.MultiThreadedEventLoopGroup.(runTheLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(thread: NIOPosix.NIOThread, parentGroup: Swift.Optional, canEventLoopBeShutdownIndividually: Swift.Bool, selectorFactory: () throws -> NIOPosix.Selector, initializer: (NIOPosix.NIOThread) -> (), _: (NIOPosix.SelectableEventLoop) -> ()) -> () at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:95
0x55766506411c, closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, parentGroup: NIOPosix.MultiThreadedEventLoopGroup, selectorFactory: () throws -> NIOPosix.Selector, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:116
0x5576650698fb, partial apply forwarder for closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, parentGroup: NIOPosix.MultiThreadedEventLoopGroup, selectorFactory: () throws -> NIOPosix.Selector, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /root/dx_3/x-bot/:0
0x5576650dca9e, reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /root/dx_3/x-bot/:0
0x5576650df5d1, closure #1 (Swift.Optional) -> Swift.Optional in static NIOPosix.ThreadOpsPosix.run(handle: inout Swift.Optional, args: NIOPosix.Box<(body: (NIOPosix.NIOThread) -> (), name: Swift.Optional)>, detachThread: Swift.Bool) -> () at /root/dx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:105
0x5576650df6d8, @objc closure #1 (Swift.Optional) -> Swift.Optional in static NIOPosix.ThreadOpsPosix.run(handle: inout Swift.Optional, args: NIOPosix.Box<(body: (NIOPosix.NIOThread) -> (), name: Swift.Optional)>, detachThread: Swift.Bool) -> () at /root/dx_3/x-bot/:0
0x7fac38abb608
0x7fac38022132
0xffffffffffffffff
dnadoba added a commit to dnadoba/async-http-client that referenced this issue Mar 13, 2023
If the channel is closed before flatMap is executed, all ChannelHandler are removed and `TLSEventsHandler` is therefore not present either. We need to tolerate this even though it is very rare.

Testing ideas welcome.

Fixes swift-server#670
@dnadoba
Copy link
Collaborator

dnadoba commented Mar 13, 2023

Thanks for the report! Should be fixed by #671

dnadoba added a commit that referenced this issue Mar 14, 2023
* Fix crash if connection is closed very early

If the channel is closed before flatMap is executed, all ChannelHandler are removed and `TLSEventsHandler` is therefore not present either. We need to tolerate this even though it is very rare.

Testing ideas welcome.

Fixes #670

* drop precondition to assert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants