@dev-anywhere/proxy 0.4.75 → 0.4.76

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.
package/dist/serve.js CHANGED
@@ -1251,13 +1251,21 @@ function extractConversationPayload(msg) {
1251
1251
  }
1252
1252
  async function extractTitleAndCwd(filePath) {
1253
1253
  return new Promise((resolve3) => {
1254
+ const input = createReadStream(filePath, { encoding: "utf-8" });
1254
1255
  const rl = createInterface({
1255
- input: createReadStream(filePath, { encoding: "utf-8" }),
1256
+ input,
1256
1257
  crlfDelay: Infinity
1257
1258
  });
1258
1259
  let resolved = false;
1259
1260
  let cwd = null;
1260
1261
  let title = null;
1262
+ const finish = () => {
1263
+ if (resolved) return;
1264
+ resolved = true;
1265
+ rl.close();
1266
+ input.destroy();
1267
+ resolve3({ title, cwd });
1268
+ };
1261
1269
  rl.on("line", (line) => {
1262
1270
  if (resolved) return;
1263
1271
  if (!line.trim()) return;
@@ -1271,17 +1279,14 @@ async function extractTitleAndCwd(filePath) {
1271
1279
  if (text) title = text;
1272
1280
  }
1273
1281
  if (cwd && title) {
1274
- resolved = true;
1275
- rl.close();
1282
+ finish();
1276
1283
  }
1277
1284
  } catch {
1278
1285
  }
1279
1286
  });
1280
- rl.on("close", () => {
1281
- if (!resolved) resolve3({ title, cwd });
1282
- else resolve3({ title, cwd });
1283
- });
1284
- rl.on("error", () => resolve3({ title, cwd }));
1287
+ rl.on("close", finish);
1288
+ rl.on("error", finish);
1289
+ input.on("error", finish);
1285
1290
  });
1286
1291
  }
1287
1292
  async function collectJsonlFiles(root) {
@@ -1304,14 +1309,24 @@ async function collectJsonlFiles(root) {
1304
1309
  }
1305
1310
  async function extractCodexTitleAndCwd(filePath) {
1306
1311
  return new Promise((resolve3) => {
1312
+ const input = createReadStream(filePath, { encoding: "utf-8" });
1307
1313
  const rl = createInterface({
1308
- input: createReadStream(filePath, { encoding: "utf-8" }),
1314
+ input,
1309
1315
  crlfDelay: Infinity
1310
1316
  });
1317
+ let resolved = false;
1311
1318
  let id = null;
1312
1319
  let cwd = null;
1313
1320
  let title = null;
1321
+ const finish = () => {
1322
+ if (resolved) return;
1323
+ resolved = true;
1324
+ rl.close();
1325
+ input.destroy();
1326
+ resolve3({ id, title, cwd });
1327
+ };
1314
1328
  rl.on("line", (line) => {
1329
+ if (resolved) return;
1315
1330
  if (!line.trim()) return;
1316
1331
  try {
1317
1332
  const obj = JSON.parse(line);
@@ -1323,12 +1338,13 @@ async function extractCodexTitleAndCwd(filePath) {
1323
1338
  const text = extractCodexUserText(obj.payload);
1324
1339
  if (text) title = text;
1325
1340
  }
1326
- if (id && cwd && title) rl.close();
1341
+ if (id && cwd && title) finish();
1327
1342
  } catch {
1328
1343
  }
1329
1344
  });
1330
- rl.on("close", () => resolve3({ id, title, cwd }));
1331
- rl.on("error", () => resolve3({ id, title, cwd }));
1345
+ rl.on("close", finish);
1346
+ rl.on("error", finish);
1347
+ input.on("error", finish);
1332
1348
  });
1333
1349
  }
1334
1350
  function extractCodexUserText(payload) {