{"record":{"id":"2a434f29362d62e4","repo":"XX-net/XX-Net","slug":"except-s-flush-send-s-blockingioerror-r","errorCode":null,"errorMessage":"Except %s flush_send_s BlockingIOError %r","messagePattern":"Except (.+?) flush_send_s BlockingIOError %r","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/smart_router/local/pipe_socks.py","lineNumber":262,"sourceCode":"                                    s2.port == 443 and \\\n                                    d[0] == '\\x16' and \\\n                            g.gfwlist.in_block_list(s2.host):\n                        p1 = d.find(s2.host)\n                        if p1 > 1:\n                            if b\"google\" in s2.host:\n                                p2 = d.find(b\"google\") + 3\n                            else:\n                                p2 = p1 + len(s2.host) - 6\n\n                            d1 = d[:p2]\n                            d2 = d[p2:]\n\n                            try:\n                                flush_send_s(s2, d1)\n                                s2.sent_data += len(d1)\n                                s2.sent_times += 1\n                            except BlockingIOError as e:\n                                xlog.warn(\"Except %s flush_send_s BlockingIOError %r\", s2, e)\n                                self.close(s2, \"w\")\n                                continue\n                            except Exception as e:\n                                xlog.warn(\"send split SNI:%s fail:%r\", s2.host, e)\n                                self.close(s2, \"w\")\n                                continue\n\n                            s2.add_dat(d2)\n                            d = b\"\"\n                            xlog.debug(\"pipe send split SNI:%s\", s2.host)\n\n                    if s2.buf_size == 0:\n                        try:\n                            sent = s2.send(d)\n                            s2.sent_data += sent\n                            s2.sent_times += 1\n                            # xlog.debug(\"direct send %d to %s from:%s total:%d\", sent, s2, s1, len(d))\n                        except BlockingIOError as e:","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/pipe_socks.py#L244-L280","documentation":"Logged when flush_send_s() raises BlockingIOError while writing split-SNI buffered data to the non-blocking socket s2 during the pipe loop. The send buffer is full so the OS would block; the write side of s2 is closed and the loop continues.","triggerScenarios":"Non-blocking socket s2 whose send buffer is full (slow remote peer / fast local writer) when pipe() tries to flush buffered data after SNI splitting.","commonSituations":"Slow upstream server or throttled link while large buffered data is flushed; mismatched socket timeouts; peer stalled.","solutions":["Tune/raise SO_SNDBUF on s2 or reduce the amount of buffered data before flushing","Enable/verify the buffering path so partial sends queue instead of closing the write side","Check remote peer health and network throughput; close dead connections earlier","Retry flush later instead of closing the write side on transient EAGAIN"],"exampleFix":"// before\nexcept BlockingIOError as e:\n    xlog.warn(\"Except %s flush_send_s BlockingIOError %r\", s2, e)\n    self.close(s2, \"w\")\n// after\nexcept BlockingIOError as e:\n    xlog.warn(\"Except %s flush_send_s BlockingIOError %r\", s2, e)\n    s2.set_blocking_wakeup()  # defer flush to next epoll/select cycle","handlingStrategy":"retry","validationCode":"if s2.buffered_size > HIGH_WATER: defer_flush()  # wait for writability","typeGuard":null,"tryCatchPattern":"Catch BlockingIOError separately from socket.error and treat as 'retry later', not fatal.","preventionTips":["Monitor per-socket buffered bytes and apply backpressure","Use select/epoll writability before flushing large buffers"],"tags":["network","non-blocking-socket","would-block","pipe"],"backgroundTag":"socket-would-block","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}