@skrillex1224/playwright-toolkit 3.0.11 → 3.0.12

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/index.js CHANGED
@@ -1059,7 +1059,7 @@ import { serializeError as serializeError2 } from "serialize-error";
1059
1059
 
1060
1060
  // src/internals/proxy-meter-runtime.js
1061
1061
  import { spawn, spawnSync } from "child_process";
1062
- import { existsSync, mkdirSync, readFileSync, rmSync } from "fs";
1062
+ import { createWriteStream, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
1063
1063
  import { tmpdir } from "os";
1064
1064
  import path from "path";
1065
1065
  import { fileURLToPath } from "url";
@@ -1168,6 +1168,19 @@ var ensureLogPath = () => {
1168
1168
  const label = runId ? `proxy-meter-${runId}-${suffix}.json` : `proxy-meter-${process.pid}-${suffix}.json`;
1169
1169
  return path.join(baseDir, label);
1170
1170
  };
1171
+ var ensureStdioLogPath = (logPath) => `${logPath}.stdio.log`;
1172
+ var writeChildOutput = (stream, output, prefix) => {
1173
+ if (!stream || !output) return;
1174
+ output.on("data", (chunk) => {
1175
+ const text = chunk?.toString?.() || String(chunk || "");
1176
+ if (!text) return;
1177
+ for (const line of text.split(/\r?\n/)) {
1178
+ if (!line) continue;
1179
+ stream.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${prefix} ${line}
1180
+ `);
1181
+ }
1182
+ });
1183
+ };
1171
1184
  var readSnapshot = (logPath) => {
1172
1185
  if (!logPath || !existsSync(logPath)) return null;
1173
1186
  try {
@@ -1335,6 +1348,7 @@ var startProxyMeter = (options = {}) => {
1335
1348
  observedDomainResourceTypes = /* @__PURE__ */ new Map();
1336
1349
  const port = pickFreePort();
1337
1350
  const logPath = ensureLogPath();
1351
+ const stdioLogPath = ensureStdioLogPath(logPath);
1338
1352
  const scriptPath = resolveScriptPath();
1339
1353
  const debugMode = Boolean(options.debugMode);
1340
1354
  const debugMaxEvents = Math.max(10, toSafeInt(options.debugMaxEvents) || DEFAULT_DEBUG_MAX_EVENTS);
@@ -1347,19 +1361,28 @@ var startProxyMeter = (options = {}) => {
1347
1361
  PROXY_METER_DEBUG: debugMode ? "1" : "0",
1348
1362
  PROXY_METER_DEBUG_MAX_EVENTS: String(debugMaxEvents)
1349
1363
  };
1364
+ const stdioLog = createWriteStream(stdioLogPath, { flags: "a" });
1365
+ stdioLog.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [proxy-meter-runtime] start script=${scriptPath} port=${port} snapshot=${logPath}
1366
+ `);
1350
1367
  const child = spawn(process.execPath, [scriptPath], {
1351
1368
  env,
1352
- stdio: ["ignore", "ignore", "ignore"]
1369
+ stdio: ["ignore", "pipe", "pipe"]
1353
1370
  });
1354
- child.once("exit", (code) => {
1371
+ writeChildOutput(stdioLog, child.stdout, "stdout");
1372
+ writeChildOutput(stdioLog, child.stderr, "stderr");
1373
+ child.once("exit", (code, signal) => {
1374
+ stdioLog.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [proxy-meter-runtime] exit code=${code ?? ""} signal=${signal ?? ""}
1375
+ `);
1376
+ stdioLog.end();
1355
1377
  if (code && code !== 0) {
1356
- logger2.warn(`[proxy-meter] exited with code ${code}`);
1378
+ logger2.warn(`[proxy-meter] exited with code ${code}; stdio=${stdioLogPath}`);
1357
1379
  }
1358
1380
  });
1359
1381
  runtime = {
1360
1382
  proc: child,
1361
1383
  port,
1362
1384
  logPath,
1385
+ stdioLogPath,
1363
1386
  startedAt: Date.now()
1364
1387
  };
1365
1388
  registerCleanup();