Skip to content

Commit 7022865

Browse files
committed
fix: 优化上行Grain合包流的错误处理逻辑,确保搬运Promise异常时进行清理
1 parent 5caedd9 commit 7022865

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

_worker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ async function 处理叉HTTP请求(request, yourUUID, 反代上下文 = {}) {
662662
const 上行Promise = (async () => {
663663
const 上行合包器 = 创建上行Grain合包流();
664664
const 搬运Promise = 上行合包器.readable.pipeTo(socket.writable, { signal: abortController.signal });
665-
void 搬运Promise.catch(() => { });
665+
void 搬运Promise.catch(清理);
666666
const 上行reader = request.body.getReader();
667667
const 取消上行reader = () => {
668668
try { 上行reader.cancel(abortController.signal.reason).catch(() => { }); } catch (e) { }
@@ -2644,8 +2644,9 @@ function 创建上行Grain合包流(目标字节 = 上行合包目标字节) {
26442644
写入: async (chunk) => {
26452645
const data = 数据转Uint8Array(chunk);
26462646
if (!data.byteLength) return;
2647-
if (缓冲长度 === 0 && data.byteLength >= 目标字节) {
2647+
if (data.byteLength >= 目标字节) {
26482648
清理定时器();
2649+
if (缓冲长度) await 冲刷();
26492650
await 串行写(data);
26502651
return;
26512652
}

0 commit comments

Comments
 (0)