Skip to content

[runnable] log error before shutdown - #2

Merged
capcom6 merged 1 commit into
masterfrom
runnable/log-error
May 4, 2026
Merged

[runnable] log error before shutdown#2
capcom6 merged 1 commit into
masterfrom
runnable/log-error

Conversation

@capcom6

@capcom6 capcom6 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Improved error logging for background processes that fail during startup, with errors captured and logged before graceful shutdown
    • Enhanced lifecycle management to ensure proper cleanup when initialization fails

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Walkthrough

RegisterRunnable now accepts a *zap.Logger parameter and logs errors when the runnable fails during execution, before shutting down. The zap logging package is added as a dependency.

Changes

Runnable Error Logging

Layer / File(s) Summary
Imports
runnable.go
Add go.uber.org/zap dependency for structured error logging.
Function Signature
runnable.go
RegisterRunnable returned function now accepts logger *zap.Logger as first parameter.
Error Handling
runnable.go
OnStart hook now logs runnable failed with zap.Error(err) when r.Run(ctx) fails, before invoking sh.Shutdown().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding error logging before shutdown in the runnable component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@runnable.go`:
- Around line 14-15: RegisterRunnable's public signature change
(RegisterRunnable[T Runnable]() now returns func(logger *zap.Logger, lc
fx.Lifecycle, sh fx.Shutdowner, r T)) is a breaking API change; to address this,
either revert to the previous signature or provide a backward-compatible wrapper
(add a new RegisterRunnableV2 or RegisterRunnableWithLogger that accepts
*zap.Logger while keeping the original RegisterRunnable returning func(lc
fx.Lifecycle, sh fx.Shutdowner, r T)), update exported documentation
(CHANGELOG/README) to describe the breaking change and migration path, and bump
the library semantic version (create a v2.x tag if keeping the new signature) so
external consumers of RegisterRunnable and the Runnable type can adopt the
change safely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0092693-a2e9-44ed-8e31-dbdb0e8ccf70

📥 Commits

Reviewing files that changed from the base of the PR and between f824382 and acd4a7c.

📒 Files selected for processing (1)
  • runnable.go

Comment thread runnable.go
@capcom6
capcom6 merged commit 2368b59 into master May 4, 2026
4 checks passed
@capcom6
capcom6 deleted the runnable/log-error branch May 4, 2026 07:34
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