Fatal error: SWIFT TASK CONTINUATION MISUSE: executeCancellable(_:deadline:logger:) tried to resume its continuation more than once, throwing HTTPClientError.deadlineExceeded!
shenfu1991 opened this issue · 1 comments
shenfu1991 commented
system: ubuntu20.04 ,full network request file:
// // CoreNetwokingManager.swift import Vapor import AsyncHTTPClient class CoreNetwokingManager { var API_Key: String = "" typealias SuccessType = (_ result: Any?,_ data: Data?) -> Void typealias CompleteType = (Any) -> Void func doAsyncWork(method: HTTPMethod,URLString: String,parameters: [String:Any]?, success: SuccessType?, complete: CompleteType?) async { var config = kApp.http.client.configuration let proxy = HTTPClient.Configuration.Proxy.socksServer(host: "127.0.0.1") let vc = vcArr.first! if vc.server.rawValue.contains("RN") { config.proxy = proxy } let httpClient = HTTPClient(eventLoopGroupProvider: .shared(kApp.eventLoopGroup),configuration: config) var request = HTTPClientRequest(url: URLString) request.method = method request.headers.add(name: "X-MBX-APIKEY", value: API_Key) do { let response = try await httpClient.execute(request, timeout: .seconds(15)) let body = try await response.body.collect(upTo: 1024 * 1024 * 100) // 100 MB let json = try JSONSerialization.jsonObject(with: body) if let ss = success { ss(json,Data(buffer:body)) if let cb = complete { cb(json) } }else{ if let cb = complete { cb("json error") } } }catch(let err){ if let cb = complete { cb("response error=\(err)") } } try? await httpClient.shutdown() } func request(method: HTTPMethod,URLString: String,parameters: [String:Any]?, success: SuccessType?, complete: CompleteType?){ Task { await doAsyncWork(method: method, URLString: URLString, parameters: parameters, success: success, complete: complete) } } }
logs:
"2023-02-07 07:09:39 \n当前价格: 1.445\ndesc: 暂无趋势\nname: Ju_Concurrency/CheckedContinuation.swift:184: Fatal error: SWIFT TASK CONTINUATION MISUSE: executeCancellable(_:deadline:logger:) tried to resume its continuation more than once, throwing HTTPClientError.deadlineExceeded! Current stack trace: 0 libswiftCore.so 0x00007f9f19f4dbd0 _swift_stdlib_reportFatalErrorInFile + 112 1 libswiftCore.so 0x00007f9f19c45a3c + 1419836 2 libswiftCore.so 0x00007f9f19c45863 + 1419363 3 libswiftCore.so 0x00007f9f19c44370 _assertionFailure(_:_:file:line:flags:) + 411 4 libswift_Concurrency.so 0x00007f9f19aabc68 + 97384 5 tx_3 0x000055989aab9477 + 3449975 6 tx_3 0x000055989aabcdb9 + 3464633 7 tx_3 0x000055989aaefc26 + 3673126 8 tx_3 0x000055989aaf27a9 + 3684265 9 tx_3 0x000055989b3f3ab5 + 13126325 10 tx_3 0x000055989b3f2396 + 13120406 11 tx_3 0x000055989b3f220f + 13120015 12 tx_3 0x000055989b3df98a + 13044106 13 tx_3 0x000055989b65c163 + 15651171 14 tx_3 0x000055989b3e00a1 + 13045921 15 tx_3 0x000055989aaf7135 + 3703093 16 tx_3 0x000055989b655b5c + 15625052 17 tx_3 0x000055989b6555d4 + 15623636 18 tx_3 0x000055989b6558f7 + 15624439 19 tx_3 0x000055989b67a50d + 15774989 20 tx_3 0x000055989b666583 + 15693187 21 tx_3 0x000055989b73a544 + 16561476 22 tx_3 0x000055989aab8f3f + 3448639 23 tx_3 0x000055989b73dab4 + 16575156 24 tx_3 0x000055989b733422 + 16532514 25 tx_3 0x000055989b738771 + 16553841 26 tx_3 0x000055989b6ffdd7 + 16322007 27 tx_3 0x000055989b7004dd + 16323805 28 tx_3 0x000055989b70613c + 16347452 29 tx_3 0x000055989b6fea0f + 16316943 30 tx_3 0x000055989b771d81 + 16788865 31 tx_3 0x000055989b7748d2 + 16799954 32 tx_3 0x000055989b774a09 + 16800265 33 libpthread.so.0 0x00007f9f19059609 + 34313 34 libc.so.6 0x00007f9f18cc20f0 clone + 67 Received signal 4. Backtrace: Gu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 \n当前价格: 4.21\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 2, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 2, ma360LowerMa120: 2)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 \n当前价格: 2.0102\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 1, lastBiggerMa120: 2, ma360LowerMa180: 2, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 \n当前价格: 14.7595\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 \n当前价格: 11.013\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 2, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 2, ma360LowerMa120: 2)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 JuGuCore() \n\n\n" "2023-02-07 07:09:39 \n当前价格: 0.7473\ndesc: 开多\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 1, check46: 1, mo: 1, lastBiggerMa360: 1, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 \n当前价格: 0.02848\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 2, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 2, ma360LowerMa120: 2)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:39 JuGuCore() 币安接口小黑屋...response error=HTTPClientError.deadlineExceeded \n\n\n" "JuGuCore() 币安接口小黑屋..." "2023-02-07 07:09:40 JuGuCore() \n\n\n" "2023-02-07 07:09:41 JuGuCore() \n\n\n" "2023-02-07 07:09:42 \n当前价格: 1614.08\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 2, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:42 \n当前价格: 22766.1\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:42 \n当前价格: 1.447\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:42 \n当前价格: 2.0108\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 1, lastBiggerMa120: 2, ma360LowerMa180: 2, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:42 \n当前价格: 14.8204\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 1, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 1, ma360LowerMa120: 1)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:42 \n当前价格: 4.225\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37: 2, check46: 2, mo: 2, lastBiggerMa360: 2, lastBiggerMa180: 2, lastBiggerMa120: 2, ma360LowerMa180: 2, ma360LowerMa120: 2)\ntime: 2023-02-07 07:09 \n\n\n" "2023-02-07 07:09:42 \n当前价格: 11.03\ndesc: 暂无趋势\nname: JuGu53(_:ssOp:)\nx: 2.0\njuguCore: JuguCoreCase(check37:0x55989aeb5472, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /root/tx_3/x-bot/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66 0x55989aeb56b9, closure #1 (Swift.Int32) -> () in static Backtrace.Backtrace.install(signals: Swift.Array) -> () at /root/tx_3/x-bot/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:80 0x55989aeb56d8, @objc closure #1 (Swift.Int32) -> () in static Backtrace.Backtrace.install(signals: Swift.Array) -> () at /root/tx_3/x-bot/:0 0x7f9f1906541f 0x7f9f19c44517 0x7f9f19aabc67 0x55989aab9476, AsyncHTTPClient.Transaction.willExecuteRequest(AsyncHTTPClient.HTTPRequestExecutor) -> () at /root/tx_3/x-bot/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/AsyncAwait/Transaction.swift:178 0x55989aabcdb8, protocol witness for AsyncHTTPClient.HTTPExecutableRequest.willExecuteRequest(AsyncHTTPClient.HTTPRequestExecutor) -> () in conformance AsyncHTTPClient.Transaction : AsyncHTTPClient.HTTPExecutableRequest in AsyncHTTPClient at /root/tx_3/x-bot/:0 0x55989aaefc25, AsyncHTTPClient.HTTP2ClientRequestHandler.write(context: NIOCore.ChannelHandlerContext, data: NIOCore.NIOAny, promise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/ConnectionPool/HTTP2/HTTP2ClientRequestHandler.swift:113 0x55989aaf27a8, protocol witness for NIOCore._ChannelOutboundHandler.write(context: NIOCore.ChannelHandlerContext, data: NIOCore.NIOAny, promise: Swift.Optional>) -> () in conformance AsyncHTTPClient.HTTP2ClientRequestHandler : NIOCore._ChannelOutboundHandler in AsyncHTTPClient at /root/tx_3/x-bot/:0 0x55989b3f3ab4, NIOCore.ChannelHandlerContext.(invokeWrite in _F5AC316541457BD146E3694279514AA3)(_: NIOCore.NIOAny, promise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1782 0x55989b3f2395, NIOCore.ChannelPipeline.(write0 in _F5AC316541457BD146E3694279514AA3)(_: NIOCore.NIOAny, promise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:825 0x55989b3f220e, NIOCore.ChannelPipeline.write(_: NIOCore.NIOAny, promise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:735 0x55989b3df989, (extension in NIOCore):NIOCore.Channel.write(_: NIOCore.NIOAny, promise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/Channel.swift:181 0x55989b65c162, protocol witness for NIOCore.ChannelOutboundInvoker.write(_: NIOCore.NIOAny, promise: Swift.Optional>) -> () in conformance NIOHTTP2.HTTP2StreamChannel : NIOCore.ChannelOutboundInvoker in NIOHTTP2 at /root/tx_3/x-bot/:0 0x55989b3e00a0, (extension in NIOCore):NIOCore.Channel.write(_: A1, promise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/Channel.swift:228 0x55989aaf7134, closure #1 (NIOCore.Channel) -> NIOCore.EventLoopFuture<()> in AsyncHTTPClient.HTTP2Connection.(executeRequest0 in _2EE1BB95339449479985810A70FBE2AE)(AsyncHTTPClient.HTTPExecutableRequest) -> () at /root/tx_3/x-bot/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/ConnectionPool/HTTP2/HTTP2Connection.swift:248 0x55989b655b5b, closure #1 (Swift.Result) -> () in NIOHTTP2.HTTP2StreamChannel.configure(initializer: Swift.Optional<(NIOCore.Channel) -> NIOCore.EventLoopFuture<()>>, userPromise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio-http2/Sources/NIOHTTP2/HTTP2StreamChannel.swift:226 0x55989b6555d3, NIOHTTP2.HTTP2StreamChannel.(getAutoReadFromParent in _5469B6D9C081B4CA091A1908ADC063BC)((Swift.Result) -> ()) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio-http2/Sources/NIOHTTP2/HTTP2StreamChannel.swift:251 0x55989b6558f6, NIOHTTP2.HTTP2StreamChannel.configure(initializer: Swift.Optional<(NIOCore.Channel) -> NIOCore.EventLoopFuture<()>>, userPromise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio-http2/Sources/NIOHTTP2/HTTP2StreamChannel.swift:221 0x55989b67a50c, NIOHTTP2.MultiplexerAbstractChannel.configure(initializer: Swift.Optional<(NIOCore.Channel) -> NIOCore.EventLoopFuture<()>>, userPromise: Swift.Optional>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio-http2/Sources/NIOHTTP2/MultiplexerAbstractChannel.swift:106 0x55989b666582, closure #1 () -> () in NIOHTTP2.HTTP2StreamMultiplexer.createStreamChannel(promise: Swift.Optional>, _: (NIOCore.Channel) -> NIOCore.EventLoopFuture<()>) -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio-http2/Sources/NIOHTTP2/HTTP2StreamMultiplexer.swift:386 0x55989b73a543, closure #4 () -> () in NIOPosix.SelectableEventLoop.run() throws -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:542 0x55989aab8f3e, reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error) at /root/tx_3/x-bot/:0 0x55989b73dab3, reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".11" at /root/tx_3/x-bot/:0 0x55989b733421, NIOPosix.withAutoReleasePool(() throws -> A) throws -> A at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:29 0x55989b738770, NIOPosix.SelectableEventLoop.run() throws -> () at /root/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:541 0x55989b6ffdd6, 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/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:95 0x55989b7004dc, 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/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:116 0x55989b70613b, 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/tx_3/x-bot/:0 0x55989b6fea0e, reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /root/tx_3/x-bot/:0 0x55989b771d80, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /root/tx_3/x-bot/:0 0x55989b7748d1, 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/tx_3/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:105 0x55989b774a08, @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/tx_3/x-bot/:0 0x7f9f19059608 0x7f9f18cc2132 0xffffffffffffffff
dnadoba commented
This looks like it is a bug in AsyncHTTPClient. Will take a closer look in the coming days.