Repository navigation
Version 4.0.0 - #12
Conversation
|
This comment has been minimized.
This comment has been minimized.
| for (const key of Object.keys(obj)) { | ||
| result[key] = cloneDeep(obj[key], logErrors, maxDepth, depth + 1) |
There was a problem hiding this comment.
Nested buffers hide log details
With preprocessors: ["maskSecrets"] and the default clone: true, logging {payload: Buffer.from("abc"), message: "request failed"} now produces "[object Object]" instead of JSON. The recursive copy gives the nested buffer Buffer.prototype but no backing bytes. Its toJSON() fails, so argumentsParser falls back to the outer object's string, hiding even its ordinary fields.
Previously, the shallow copy preserved the nested buffer. Copy buffers with Buffer.from() before the generic object branch.
There was a problem hiding this comment.
Fixed in b941f5a. cloneDeep now only copies plain objects, arrays, errors and dates. Buffers, other built-ins and class instances are kept as they are, so the nested buffer serializes as before.
There was a problem hiding this comment.
1 issue found across 39 files
Confidence score: 4/5
- In
src/preprocessors.ts,friendlyErrorstreats successful fetch responses as failures, so they can be logged asCode 200 | OK. Only extract error details whenobj.ok === false.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/preprocessors.ts">
<violation number="1" location="src/preprocessors.ts:150">
P2: `friendlyErrors` treats successful fetch responses as failures because this condition only checks that `ok` is boolean. Logging a successful `Response` becomes `Code 200 | OK`; require `obj.ok === false` before extracting failure details.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Turn on auto-fix | Re-trigger cubic
| } | ||
|
|
||
| // Failed fetch() response, the body can't be read synchronously. | ||
| else if (typeof obj.ok == "boolean" && typeof obj.status == "number" && isFunction(obj.headers?.get)) { |
There was a problem hiding this comment.
P2: friendlyErrors treats successful fetch responses as failures because this condition only checks that ok is boolean. Logging a successful Response becomes Code 200 | OK; require obj.ok === false before extracting failure details.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/preprocessors.ts, line 150:
<comment>`friendlyErrors` treats successful fetch responses as failures because this condition only checks that `ok` is boolean. Logging a successful `Response` becomes `Code 200 | OK`; require `obj.ok === false` before extracting failure details.</comment>
<file context>
@@ -138,6 +140,16 @@ class AnyhowPreProcessors {
+ }
+
+ // Failed fetch() response, the body can't be read synchronously.
+ else if (typeof obj.ok == "boolean" && typeof obj.status == "number" && isFunction(obj.headers?.get)) {
+ arrError.push(`Code ${obj.status}`)
+ if (obj.statusText) arrError.push(obj.statusText)
</file context>
| else if (typeof obj.ok == "boolean" && typeof obj.status == "number" && isFunction(obj.headers?.get)) { | |
| else if (obj.ok === false && typeof obj.status == "number" && isFunction(obj.headers?.get)) { |
There was a problem hiding this comment.
Not changing this one. The output only shows the status, it doesn't label the response as an error. Requiring ok === false would make a successful Response log as {}, since all its properties are getters, which loses useful information.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Anyhow 4.0.0
Native ESM support
The package now ships both CommonJS and ESM entry points through
package.jsonexports. Bothrequire("anyhow")andimport logger from "anyhow"resolve to the same singleton instance, with matching type declarations for each format.Node.js 22 or newer (breaking)
The minimum supported Node.js version is now 22. The TypeScript configuration targets modern Node module resolution.
New
levelMapoptionMaps Anyhow levels to the level names supported by the configured logger or console, for example
{debug: "trace"}. Enabled levels and console styles still use the original Anyhow level; only the level passed to the logger or the console method changes.Full JSON on
debug()debug()now logs the full JSON of the passed objects, keeping nested arrays and string values intact. Only themaskSecretspreprocessor runs for debug logs, so secrets are still masked.Other changes
unhandledRejections: falsenot removing the registered handler.