@zuplo/cli 6.60.37 → 6.61.1

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.
@@ -4,14 +4,9 @@ export declare function handleRuntimeStdio(
4
4
  stdout: Readable,
5
5
  stderr: Readable
6
6
  ): void;
7
- export declare function logConsole(
8
- level: LogLevel,
9
- data: string,
10
- callDepth?: number
11
- ): void;
7
+ export declare function logConsole(level: LogLevel, data: string): void;
12
8
  export declare function logConsoleAsync(
13
9
  level: LogLevel,
14
- data: string,
15
- callDepth?: number
10
+ data: string
16
11
  ): Promise<void>;
17
12
  //# sourceMappingURL=worker-output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-output.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAiC,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,QA2JpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,SAAI,QAEtE;AAKD,wBAAsB,eAAe,CACnC,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,MAAM,EACZ,SAAS,SAAI,iBAwDd"}
1
+ {"version":3,"file":"worker-output.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAiC,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,QAoMpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAEvD;AAKD,wBAAsB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBA2ClE"}
@@ -4,6 +4,8 @@ const logFormatter = new LogFormatter(async (path) => {
4
4
  return readFile(path, { encoding: "utf8" });
5
5
  });
6
6
  export function handleRuntimeStdio(stdout, stderr) {
7
+ let stdoutAccumulator = "";
8
+ let stderrAccumulator = "";
7
9
  const classifiers = {
8
10
  isBarf(chunk) {
9
11
  const containsLlvmSymbolizerWarning = chunk.includes("Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set");
@@ -30,71 +32,103 @@ export function handleRuntimeStdio(stdout, stderr) {
30
32
  },
31
33
  };
32
34
  stdout.on("data", (chunk) => {
33
- chunk = chunk.toString().trim();
34
- if (classifiers.isBarf(chunk)) {
35
- logConsole("debug", chunk);
35
+ const fullStreamOutput = `${stdoutAccumulator}${chunk}`;
36
+ let currentLogsStr = "";
37
+ const lastNewlineIdx = fullStreamOutput.lastIndexOf("\n");
38
+ if (lastNewlineIdx > 0) {
39
+ currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);
40
+ stdoutAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);
36
41
  }
37
- else if (classifiers.isWarning(chunk)) {
38
- logConsole("warn", chunk);
42
+ else {
43
+ stdoutAccumulator = fullStreamOutput;
44
+ return;
39
45
  }
40
- else if (classifiers.isZenoLog(chunk)) {
41
- const levels = ["debug", "info", "warn", "error"];
42
- const level = levels.find((level) => chunk.includes(`[${level.toUpperCase()}]`));
43
- chunk = chunk.substring("[ZENO]:".length);
44
- chunk = chunk.substring(`[${level?.toUpperCase()}]`.length);
45
- if (level) {
46
- logConsole(level, chunk);
46
+ const lines = currentLogsStr.split("\n");
47
+ for (let line of lines) {
48
+ line = line.trim();
49
+ if (!line)
50
+ continue;
51
+ if (classifiers.isBarf(line)) {
52
+ logConsole("debug", line);
53
+ }
54
+ else if (classifiers.isWarning(line)) {
55
+ logConsole("warn", line);
56
+ }
57
+ else if (classifiers.isZenoLog(line)) {
58
+ const levels = ["debug", "info", "warn", "error"];
59
+ const level = levels.find((level) => line.includes(`[${level.toUpperCase()}]`));
60
+ line = line.substring("[ZENO]:".length);
61
+ line = line.substring(`[${level?.toUpperCase()}]`.length);
62
+ if (level) {
63
+ logConsole(level, line);
64
+ }
65
+ else {
66
+ logConsole("info", line);
67
+ }
47
68
  }
48
69
  else {
49
- logConsole("info", chunk);
70
+ logConsole("error", line);
50
71
  }
51
72
  }
52
- else {
53
- logConsole("error", chunk);
54
- }
55
73
  });
56
74
  stderr.on("data", (chunk) => {
57
- chunk = chunk.toString().trim();
58
- if (classifiers.isBarf(chunk)) {
59
- if (classifiers.isAddressInUse(chunk)) {
60
- const address = chunk.match(/Address already in use; toString\(\) = (.+)\n/)?.[1];
61
- logConsole("error", `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`);
62
- logConsole("debug", chunk);
63
- }
64
- else if (classifiers.isAccessViolation(chunk)) {
65
- let error = "There was an access violation in the runtime.";
66
- if (process.platform === "win32") {
67
- error +=
68
- "\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\n" +
69
- "Check that you have the latest version installed.\n" +
70
- "See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.";
75
+ const fullStreamOutput = `${stderrAccumulator}${chunk}`;
76
+ let currentLogsStr = "";
77
+ const lastNewlineIdx = fullStreamOutput.lastIndexOf("\n");
78
+ if (lastNewlineIdx > 0) {
79
+ currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);
80
+ stderrAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);
81
+ }
82
+ else {
83
+ stderrAccumulator = fullStreamOutput;
84
+ return;
85
+ }
86
+ const lines = currentLogsStr.split("\n");
87
+ for (let line of lines) {
88
+ line = line.trim();
89
+ if (!line)
90
+ continue;
91
+ if (classifiers.isBarf(line)) {
92
+ if (classifiers.isAddressInUse(line)) {
93
+ const address = line.match(/Address already in use; toString\(\) = (.+)\n/)?.[1];
94
+ logConsole("error", `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`);
95
+ logConsole("debug", line);
71
96
  }
72
- logConsole("error", error);
73
- logConsole("debug", chunk);
97
+ else if (classifiers.isAccessViolation(line)) {
98
+ let error = "There was an access violation in the runtime.";
99
+ if (process.platform === "win32") {
100
+ error +=
101
+ "\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\n" +
102
+ "Check that you have the latest version installed.\n" +
103
+ "See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.";
104
+ }
105
+ logConsole("error", error);
106
+ logConsole("debug", line);
107
+ }
108
+ else {
109
+ logConsole("debug", line);
110
+ }
111
+ }
112
+ else if (classifiers.isWarning(line)) {
113
+ logConsole("warn", line);
114
+ }
115
+ else if (classifiers.isCodeMovedWarning(line)) {
116
+ }
117
+ else if (classifiers.isZenoLog(line)) {
118
+ line = line.substring("[ZENO]:".length);
119
+ line = line.substring("[ERROR]".length);
120
+ logConsole("error", line);
74
121
  }
75
122
  else {
76
- logConsole("debug", chunk);
123
+ logConsole("error", line);
77
124
  }
78
125
  }
79
- else if (classifiers.isWarning(chunk)) {
80
- logConsole("warn", chunk);
81
- }
82
- else if (classifiers.isCodeMovedWarning(chunk)) {
83
- }
84
- else if (classifiers.isZenoLog(chunk)) {
85
- chunk = chunk.substring("[ZENO]:".length);
86
- chunk = chunk.substring("[ERROR]".length);
87
- logConsole("error", chunk);
88
- }
89
- else {
90
- logConsole("error", chunk);
91
- }
92
126
  });
93
127
  }
94
- export function logConsole(level, data, callDepth = 0) {
95
- void logConsoleAsync(level, data, callDepth);
128
+ export function logConsole(level, data) {
129
+ void logConsoleAsync(level, data);
96
130
  }
97
- export async function logConsoleAsync(level, data, callDepth = 0) {
131
+ export async function logConsoleAsync(level, data) {
98
132
  try {
99
133
  if (!data) {
100
134
  return;
@@ -113,15 +147,8 @@ export async function logConsoleAsync(level, data, callDepth = 0) {
113
147
  logEntry = JSON.parse(message);
114
148
  }
115
149
  catch {
116
- if (callDepth === 1) {
117
- const lines = message.split("\n");
118
- await Promise.all(lines.map(async (line) => logConsole(level, line, callDepth++)));
119
- return;
120
- }
121
- else {
122
- console[level](data);
123
- return;
124
- }
150
+ console[level](data);
151
+ return;
125
152
  }
126
153
  await Promise.all(logEntry.messages.map(async (msg) => {
127
154
  const line = await logFormatter.formatStructured(logEntry, msg);
@@ -1 +1 @@
1
- {"version":3,"file":"worker-output.js","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,MAAgB,EAAE,MAAgB;IAKnE,MAAM,WAAW,GAAG;QAElB,MAAM,CAAC,KAAa;YAClB,MAAM,6BAA6B,GAAG,KAAK,CAAC,QAAQ,CAClD,kEAAkE,CACnE,CAAC;YACF,MAAM,mCAAmC,GAAG,KAAK,CAAC,QAAQ,CACxD,6BAA6B,CAC9B,CAAC;YAIF,MAAM,gBAAgB,GAAG,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEpE,OAAO,CACL,6BAA6B;gBAC7B,mCAAmC;gBACnC,gBAAgB,CACjB,CAAC;QACJ,CAAC;QAED,cAAc,CAAC,KAAa;YAC1B,OAAO,KAAK,CAAC,QAAQ,CAAC,uCAAuC,CAAC,CAAC;QACjE,CAAC;QACD,SAAS,CAAC,KAAa;YACrB,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,kBAAkB,CAAC,KAAa;YAC9B,OAAO,mC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CAAC;gBAGP,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;oBAGpB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAClC,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAChE,CAAC;oBACF,OAAO;gBACT,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;oBACrB,OAAO;gBACT,CAAC;YACH,CAAC;YACD,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAChE,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAEpD,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/** biome-ignore-all lint/suspicious/noConsole: Output */\nimport { Readable } from \"node:stream\";\nimport { ConsoleLogEntry, LogFormatter, LogLevel } from \"@zuplo/core/cli\";\nimport { readFile } from \"node:fs/promises\";\n\nconst logFormatter = new LogFormatter(async (path: string) => {\n return readFile(path, { encoding: \"utf8\" });\n});\n\nexport function handleRuntimeStdio(stdout: Readable, stderr: Readable) {\n // ASSUMPTION: each chunk is a whole message from workerd\n // This may not hold across OSes/architectures, but it seems to work on macOS M-line\n // I'm going with this simple approach to avoid complicating this too early\n // We can iterate on this heuristic in the future if it causes issues\n const classifiers = {\n // Is this chunk a big chonky barf from workerd that we want to hijack to cleanup/ignore?\n isBarf(chunk: string) {\n const containsLlvmSymbolizerWarning = chunk.includes(\n \"Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set\"\n );\n const containsRecursiveIsolateLockWarning = chunk.includes(\n \"took recursive isolate lock\"\n );\n // Matches stack traces from workerd\n // - on unix: groups of 9 hex digits separated by spaces\n // - on windows: groups of 12 hex digits, or a single digit 0, separated by spaces\n const containsHexStack = /stack:( (0|[a-f\\d]{4,})){3,}/.test(chunk);\n\n return (\n containsLlvmSymbolizerWarning ||\n containsRecursiveIsolateLockWarning ||\n containsHexStack\n );\n },\n // Is this chunk an Address In Use error?\n isAddressInUse(chunk: string) {\n return chunk.includes(\"Address already in use; toString() = \");\n },\n isWarning(chunk: string) {\n return /\\.c\\+\\+:\\d+: warning:/.test(chunk);\n },\n isCodeMovedWarning(chunk: string) {\n return /CODE_MOVED for unknown code block/.test(chunk);\n },\n isAccessViolation(chunk: string) {\n return chunk.includes(\"access violation;\");\n },\n isZenoLog(chunk: string) {\n return chunk.startsWith(\"[ZENO]:\");\n },\n };\n\n stdout.on(\"data\", (chunk: Buffer | string) => {\n chunk = chunk.toString().trim();\n\n if (classifiers.isBarf(chunk)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // there are no known cases to cleanup yet\n // but, as they are identified, we will do that here\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n logConsole(\"debug\", chunk);\n }\n\n // known case: warnings are not info, log them as such\n else if (classifiers.isWarning(chunk)) {\n logConsole(\"warn\", chunk);\n } else if (classifiers.isZenoLog(chunk)) {\n // Route to the specified logging level\n const levels = [\"debug\", \"info\", \"warn\", \"error\"];\n const level = levels.find((level) =>\n chunk.includes(`[${level.toUpperCase()}]`)\n );\n // Strip the prefixes for zeno and the zeno logging level\n chunk = chunk.substring(\"[ZENO]:\".length);\n chunk = chunk.substring(`[${level?.toUpperCase()}]`.length);\n if (level) {\n logConsole(level as LogLevel, chunk);\n } else {\n logConsole(\"info\", chunk);\n }\n }\n\n // anything not explicitly handled above should be logged as info (via stdout)\n else {\n logConsole(\"error\", chunk);\n }\n });\n\n stderr.on(\"data\", (chunk: Buffer | string) => {\n chunk = chunk.toString().trim();\n\n if (classifiers.isBarf(chunk)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // known case to cleanup: Address in use errors\n if (classifiers.isAddressInUse(chunk)) {\n const address = chunk.match(\n /Address already in use; toString\\(\\) = (.+)\\n/\n )?.[1];\n\n logConsole(\n \"error\",\n `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`\n );\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", chunk);\n }\n // In the past we have seen Access Violation errors on Windows, which may be caused by an outdated\n // version of the Windows OS or the Microsoft Visual C++ Redistributable.\n // See https://github.com/cloudflare/workers-sdk/issues/6170#issuecomment-2245209918\n else if (classifiers.isAccessViolation(chunk)) {\n let error = \"There was an access violation in the runtime.\";\n if (process.platform === \"win32\") {\n error +=\n \"\\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\\n\" +\n \"Check that you have the latest version installed.\\n\" +\n \"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.\";\n }\n logConsole(\"error\", error);\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", chunk);\n }\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n else {\n logConsole(\"debug\", chunk);\n }\n }\n\n // known case: warnings are not errors, log them as such\n else if (classifiers.isWarning(chunk)) {\n logConsole(\"warn\", chunk);\n }\n\n // known case: \"error: CODE_MOVED for unknown code block?\", warning for workerd devs, not application devs\n else if (classifiers.isCodeMovedWarning(chunk)) {\n // ignore entirely, don't even send it to the debug log file\n }\n\n // Handle Zeno error logs\n else if (classifiers.isZenoLog(chunk)) {\n // Strip the prefixes\n chunk = chunk.substring(\"[ZENO]:\".length);\n chunk = chunk.substring(\"[ERROR]\".length);\n logConsole(\"error\", chunk);\n }\n\n // anything not explicitly handled above should be logged as an error (via stderr)\n else {\n logConsole(\"error\", chunk);\n }\n });\n}\n\nexport function logConsole(level: LogLevel, data: string, callDepth = 0) {\n void logConsoleAsync(level, data, callDepth);\n}\n\n/**\n * This is what is logged when the runtime calls console.log, etc.\n */\nexport async function logConsoleAsync(\n level: LogLevel,\n data: string,\n callDepth = 0\n) {\n try {\n if (!data) {\n return;\n }\n\n // This shouldn't happen, but just in case\n if (typeof data !== \"string\") {\n console[level](data);\n return;\n }\n\n let message = data?.trim();\n if (!message || message?.length === 0) {\n return;\n }\n\n // Probably a JSON object\n if (message.startsWith(`{`) && message.endsWith(`}`)) {\n let logEntry: ConsoleLogEntry;\n try {\n logEntry = JSON.parse(message);\n } catch {\n // If we are at a depth of 1 it means we are trying to handle the case\n // where a chunk might be multiple JSON entries.\n if (callDepth === 1) {\n // We might have multiple log entries in a single chunk\n // so split them and log each one\n const lines = message.split(\"\\n\");\n await Promise.all(\n lines.map(async (line) => logConsole(level, line, callDepth++))\n );\n return;\n } else {\n console[level](data);\n return;\n }\n }\n await Promise.all(\n logEntry.messages.map(async (msg) => {\n const line = await logFormatter.formatStructured(logEntry, msg);\n console[level](line);\n })\n );\n } else {\n message = await logFormatter.formatMessage(message);\n\n const line = logFormatter.formatLine(level, message);\n console[level](line);\n }\n } catch {\n const line = logFormatter.formatLine(level, data);\n\n console[level](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AAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAChE,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAEpD,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/** biome-ignore-all lint/suspicious/noConsole: Output */\nimport { Readable } from \"node:stream\";\nimport { ConsoleLogEntry, LogFormatter, LogLevel } from \"@zuplo/core/cli\";\nimport { readFile } from \"node:fs/promises\";\n\nconst logFormatter = new LogFormatter(async (path: string) => {\n return readFile(path, { encoding: \"utf8\" });\n});\n\nexport function handleRuntimeStdio(stdout: Readable, stderr: Readable) {\n let stdoutAccumulator = \"\";\n let stderrAccumulator = \"\";\n\n const classifiers = {\n // Is this chunk a big chonky barf from workerd that we want to hijack to cleanup/ignore?\n isBarf(chunk: string) {\n const containsLlvmSymbolizerWarning = chunk.includes(\n \"Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set\"\n );\n const containsRecursiveIsolateLockWarning = chunk.includes(\n \"took recursive isolate lock\"\n );\n // Matches stack traces from workerd\n // - on unix: groups of 9 hex digits separated by spaces\n // - on windows: groups of 12 hex digits, or a single digit 0, separated by spaces\n const containsHexStack = /stack:( (0|[a-f\\d]{4,})){3,}/.test(chunk);\n\n return (\n containsLlvmSymbolizerWarning ||\n containsRecursiveIsolateLockWarning ||\n containsHexStack\n );\n },\n // Is this chunk an Address In Use error?\n isAddressInUse(chunk: string) {\n return chunk.includes(\"Address already in use; toString() = \");\n },\n isWarning(chunk: string) {\n return /\\.c\\+\\+:\\d+: warning:/.test(chunk);\n },\n isCodeMovedWarning(chunk: string) {\n return /CODE_MOVED for unknown code block/.test(chunk);\n },\n isAccessViolation(chunk: string) {\n return chunk.includes(\"access violation;\");\n },\n isZenoLog(chunk: string) {\n return chunk.startsWith(\"[ZENO]:\");\n },\n };\n\n stdout.on(\"data\", (chunk: Buffer | string) => {\n const fullStreamOutput = `${stdoutAccumulator}${chunk}`;\n\n let currentLogsStr = \"\";\n const lastNewlineIdx = fullStreamOutput.lastIndexOf(\"\\n\");\n\n if (lastNewlineIdx > 0) {\n // Extract complete logs up to the last newline\n currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);\n // Save the partial/incomplete log for next iteration\n stdoutAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);\n } else {\n // No complete log found, accumulate entire output\n stdoutAccumulator = fullStreamOutput;\n return;\n }\n\n const lines = currentLogsStr.split(\"\\n\");\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (classifiers.isBarf(line)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // there are no known cases to cleanup yet\n // but, as they are identified, we will do that here\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n logConsole(\"debug\", line);\n }\n\n // known case: warnings are not info, log them as such\n else if (classifiers.isWarning(line)) {\n logConsole(\"warn\", line);\n } else if (classifiers.isZenoLog(line)) {\n // Route to the specified logging level\n const levels = [\"debug\", \"info\", \"warn\", \"error\"];\n const level = levels.find((level) =>\n line.includes(`[${level.toUpperCase()}]`)\n );\n // Strip the prefixes for zeno and the zeno logging level\n line = line.substring(\"[ZENO]:\".length);\n line = line.substring(`[${level?.toUpperCase()}]`.length);\n if (level) {\n logConsole(level as LogLevel, line);\n } else {\n logConsole(\"info\", line);\n }\n }\n\n // anything not explicitly handled above should be logged as info (via stdout)\n else {\n logConsole(\"error\", line);\n }\n }\n });\n\n stderr.on(\"data\", (chunk: Buffer | string) => {\n const fullStreamOutput = `${stderrAccumulator}${chunk}`;\n\n let currentLogsStr = \"\";\n const lastNewlineIdx = fullStreamOutput.lastIndexOf(\"\\n\");\n\n if (lastNewlineIdx > 0) {\n // Extract complete logs up to the last newline\n currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);\n // Save the partial/incomplete log for next iteration\n stderrAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);\n } else {\n // No complete log found, accumulate entire output\n stderrAccumulator = fullStreamOutput;\n return;\n }\n\n const lines = currentLogsStr.split(\"\\n\");\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (classifiers.isBarf(line)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // known case to cleanup: Address in use errors\n if (classifiers.isAddressInUse(line)) {\n const address = line.match(\n /Address already in use; toString\\(\\) = (.+)\\n/\n )?.[1];\n\n logConsole(\n \"error\",\n `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`\n );\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", line);\n }\n // In the past we have seen Access Violation errors on Windows, which may be caused by an outdated\n // version of the Windows OS or the Microsoft Visual C++ Redistributable.\n // See https://github.com/cloudflare/workers-sdk/issues/6170#issuecomment-2245209918\n else if (classifiers.isAccessViolation(line)) {\n let error = \"There was an access violation in the runtime.\";\n if (process.platform === \"win32\") {\n error +=\n \"\\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\\n\" +\n \"Check that you have the latest version installed.\\n\" +\n \"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.\";\n }\n logConsole(\"error\", error);\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", line);\n }\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n else {\n logConsole(\"debug\", line);\n }\n }\n\n // known case: warnings are not errors, log them as such\n else if (classifiers.isWarning(line)) {\n logConsole(\"warn\", line);\n }\n\n // known case: \"error: CODE_MOVED for unknown code block?\", warning for workerd devs, not application devs\n else if (classifiers.isCodeMovedWarning(line)) {\n // ignore entirely, don't even send it to the debug log file\n }\n\n // Handle Zeno error logs\n else if (classifiers.isZenoLog(line)) {\n // Strip the prefixes\n line = line.substring(\"[ZENO]:\".length);\n line = line.substring(\"[ERROR]\".length);\n logConsole(\"error\", line);\n }\n\n // anything not explicitly handled above should be logged as an error (via stderr)\n else {\n logConsole(\"error\", line);\n }\n }\n });\n}\n\nexport function logConsole(level: LogLevel, data: string) {\n void logConsoleAsync(level, data);\n}\n\n/**\n * This is what is logged when the runtime calls console.log, etc.\n */\nexport async function logConsoleAsync(level: LogLevel, data: string) {\n try {\n if (!data) {\n return;\n }\n\n // This shouldn't happen, but just in case\n if (typeof data !== \"string\") {\n console[level](data);\n return;\n }\n\n let message = data?.trim();\n if (!message || message?.length === 0) {\n return;\n }\n\n // Probably a JSON object\n if (message.startsWith(`{`) && message.endsWith(`}`)) {\n let logEntry: ConsoleLogEntry;\n try {\n logEntry = JSON.parse(message);\n } catch {\n console[level](data);\n return;\n }\n await Promise.all(\n logEntry.messages.map(async (msg) => {\n const line = await logFormatter.formatStructured(logEntry, msg);\n console[level](line);\n })\n );\n } else {\n message = await logFormatter.formatMessage(message);\n\n const line = logFormatter.formatLine(level, message);\n console[level](line);\n }\n } catch {\n const line = logFormatter.formatLine(level, data);\n\n console[level](line);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "6.60.37",
3
+ "version": "6.61.1",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "@opentelemetry/api": "1.9.0",
30
30
  "@sentry/node": "9.22.0",
31
31
  "@swc/core": "1.10.18",
32
- "@zuplo/core": "6.60.37",
33
- "@zuplo/openapi-tools": "6.60.37",
34
- "@zuplo/runtime": "6.60.37",
32
+ "@zuplo/core": "6.61.1",
33
+ "@zuplo/openapi-tools": "6.61.1",
34
+ "@zuplo/runtime": "6.61.1",
35
35
  "as-table": "1.0.55",
36
36
  "chalk": "5.4.1",
37
37
  "chokidar": "3.5.3",