ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.85k stars 2.55k forks source link

The http client occasionally encounters unexpected errors #18424

Closed xiusin closed 10 months ago

xiusin commented 10 months ago

Zig Version

0.12.0-dev.1571+03adafd80

Steps to Reproduce and Observed Behavior

[INFO] Listening on http://localhost:8090/
unexpected errno: 60
/opt/zig/lib/std/debug.zig:127:31: 0x1029fbbed in dumpCurrentStackTrace (examples)
        writeCurrentStackTrace(stderr, debug_info, io.tty.detectConfig(io.getStdErr()), start_addr) catch |err| {
                              ^
/opt/zig/lib/std/os.zig:5670:40: 0x1029baae9 in unexpectedErrno (examples)
        std.debug.dumpCurrentStackTrace(null);
                                       ^
/opt/zig/lib/std/os.zig:823:49: 0x102b888f9 in readv (examples)
            else => |err| return unexpectedErrno(err),
                                                ^
/opt/zig/lib/std/net.zig:1786:24: 0x102b10028 in readv (examples)
        return os.readv(s.handle, iovecs);
                       ^
/opt/zig/lib/std/crypto/tls/Client.zig:989:45: 0x102b805ee in readvAdvanced__anon_15979 (examples)
    const actual_read_len = try stream.readv(ask_iovecs);
                                            ^
/opt/zig/lib/std/crypto/tls/Client.zig:900:38: 0x102b881c5 in readvAtLeast__anon_15978 (examples)
        var amt = try c.readvAdvanced(stream, iovecs[vec_i..]);
                                     ^
/opt/zig/lib/std/crypto/tls/Client.zig:884:24: 0x102b88692 in readv__anon_15977 (examples)
    return readvAtLeast(c, stream, iovecs, 1);
                       ^
/opt/zig/lib/std/http/Client.zig:208:37: 0x102b0fccc in readvDirectTls (examples)
        return conn.tls_client.readv(conn.stream, buffers) catch |err| {
                                    ^
/opt/zig/lib/std/http/Client.zig:225:39: 0x102a115e9 in readvDirect (examples)
            return conn.readvDirectTls(buffers);
                                      ^
/opt/zig/lib/std/http/Client.zig:241:43: 0x1029cc6cc in fill (examples)
        const nread = try conn.readvDirect(&iovecs);
                                          ^
/opt/zig/lib/std/http/Client.zig:766:42: 0x1029abe18 in wait (examples)
                try req.connection.?.fill();
                                         ^
/opt/zig/lib/std/http/Client.zig:1557:17: 0x1029a81fd in fetch (examples)
    try req.wait();
                ^
/examples/src/libs/api.zig:251:38: 0x1029aea3b in request (examples)
        const resp = try client.fetch(self.allocator, options);
                                     ^
/examples/src/libs/api.zig:111:38: 0x1029b70ff in account_positions (examples)
        var result = try self.request(api.ApiAccountPositions, .GET, ""); // This uses the http.zig network framework
                                     ^
/examples/src/libs/server.zig:49:44: 0x1029a07e8 in api_account_positions (examples)
    var tickers = try api.account_positions();
                                           ^
/Users/xiusin/.cache/zig/p/12209ab0456a3269bc04878d13137571f79411d945df9a7d71af75d968aa52fceef1/src/httpz.zig:285:30: 0x1029968d3 in defaultDispatcherWithContext (examples)
                return action(ctx, req, res);
                             ^
/Users/xiusin/.cache/zig/p/12209ab0456a3269bc04878d13137571f79411d945df9a7d71af75d968aa52fceef1/src/httpz.zig:327:37: 0x102bd63df in handle (examples)
                return da.dispatcher(da.ctx, da.action, req, res);
                                    ^
/Users/xiusin/.cache/zig/p/12209ab0456a3269bc04878d13137571f79411d945df9a7d71af75d968aa52fceef1/src/listener.zig:403:22: 0x102b4f03d in handleRequest (examples)
   if (!server.handle(&req, &res)) {
                     ^
/Users/xiusin/.cache/zig/p/12209ab0456a3269bc04878d13137571f79411d945df9a7d71af75d968aa52fceef1/src/listener.zig:320:29: 0x102a52252 in run (examples)
      if (self.handleRequest(kconn.conn, will_close)) {
                            ^
/opt/zig/lib/std/Thread.zig:412:13: 0x102a025da in callFn__anon_11130 (examples)
            @call(.auto, f, args);
            ^
/opt/zig/lib/std/Thread.zig:685:30: 0x1029baa72 in entryFn (examples)
                return callFn(f, args_ptr.*);
                             ^
???:?:?: 0x7ff815e861d2 in ??? (libsystem_pthread.dylib)
Unwind error at address `libsystem_pthread.dylib:0x7ff815e861d2` (error.InvalidDebugInfo), trace may be incomplete

???:?:?: 0x7ff815e81bd2 in ??? (libsystem_pthread.dylib)
???:?:?: 0x0 in ??? (???)

Expected Behavior

I expect it to work normally, but I don't know under what circumstances this error will be reported or what solutions are available. My system is macOS.

xiusin commented 10 months ago

error.UnexpectedReadFailure And this error report

truemedian commented 10 months ago

errno 60 corresponds to ETIMEDOUT, make sure the server you're connecting to is responding to the request in a reasonable amount of time.

xiusin commented 10 months ago

@truemedian My interface service is provided by okx. I think it's not the server timeout. I will observe the interface time consumption. Thank you for your reply.