Skip to content

feat(logger): serialize and log error cause chains in CloudflareLogger and ErrorHandler - #62

Merged
treeder merged 2 commits into
mainfrom
log_error_causes
Sep 3, 2026
Merged

feat(logger): serialize and log error cause chains in CloudflareLogger and ErrorHandler#62
treeder merged 2 commits into
mainfrom
log_error_causes

Conversation

@treeder

@treeder treeder commented Sep 3, 2026

Copy link
Copy Markdown
Owner

What

  • Adds recursive error cause formatting and serialization to CloudflareLogger and ErrorHandler.
  • Exposes serializeError(err) helper to ensure non-enumerable Error properties (message, stack, status, and nested cause) are converted into JSON-serializable objects rather than serializing to {}.
  • Appends (caused by: <cause chain>) to data.message so that root causes appear directly in single-line Cloudflare log views.
  • Formats cause chains into ErrorHandler webhook alert messages (Google Chat / Slack).
  • Adds unit test coverage for single and nested error cause chains.

Testing

  • npm test passes (14/14 test files, 28/28 tests passed).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This pull request introduces error cause chain formatting and serialization across CloudflareLogger and ErrorHandler, ensuring nested causes are included in log messages and webhook alerts. While the logging changes in logger.js are well-tested, errors.js contains a critical regression where dataStr was left undeclared, resulting in a runtime ReferenceError during webhook dispatch.

🔍 General Feedback

  • Good test coverage was added in test/logger.test.js covering both single-level and multi-level cause chain logging.
  • Consider adding unit tests for ErrorHandler (e.g. in a new test/errors.test.js) to verify webhook payload formatting and duplicate suppression logic so regressions like missing variables are caught by CI.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 7,536
Input Tokens (cached) 38,168 (⚡ 83.5% cached)
Output Tokens 706
Total Session Tokens 54,297
Cost (uncached input) $0.0057
Cost (cached input) $0.0029
Cost (output) $0.0026
Estimated Total Cost $0.0112

Gemini 3.8 Flash: introductory rate $0.75/$3.75 per 1M applied; reverts to $1.5/$7.5 after 2026-12-31.
Gemini 3.8 Flash: standard tier; batch and flex are half again, priority is higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

Comment thread errors.js
Comment thread errors.js
Comment thread logger.js Outdated
Comment thread logger.js
@treeder
treeder merged commit 386c4f2 into main Sep 3, 2026
1 check passed
@treeder
treeder deleted the log_error_causes branch September 3, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant