chatccc 0.2.236 → 0.2.237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -300,8 +300,15 @@ async function searchGzipFileLines(
300
300
  try {
301
301
  const source = createReadStream(filePath);
302
302
  const gunzip = createGunzip();
303
+ // 防崩溃(线上事故):截断/损坏的 gzip 会在 zlib 层 emit 'error'(如
304
+ // "unexpected end of file")。若无人监听,错误事件会升级为 uncaughtException
305
+ // 直接杀死整个服务(崩溃黑匣子 exit(1))。显式挂监听把错误降级为
306
+ // “跳过该文件”:destroy 流让 for await 正常结束,不再冒泡。
303
307
  source.on("error", () => gunzip.destroy());
308
+ gunzip.on("error", () => gunzip.destroy());
304
309
  const reader = createInterface({ input: source.pipe(gunzip), crlfDelay: Infinity });
310
+ // readline 会把 input 流的 error 转发到自己身上,同样需要监听避免冒泡
311
+ reader.on("error", () => {});
305
312
  for await (const line of reader) {
306
313
  bytes += Buffer.byteLength(line, "utf-8");
307
314
  if (bytes > maxBytes) break;