Conversation
…cycle test DeferNew's 10-second DeferCleanup can be too tight for the full fx shutdown chain (watermill router, nats subscriber, etc.) under CI load. Register an explicit DeferCleanup with 30s that runs first (LIFO), making DeferNew's cleanup a no-op. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughModified the "restarting the service" scenario in an e2e test to capture the restarted service in a local variable, then added explicit cleanup logic that stops the restarted service with a 30-second timeout before other deferred cleanups run. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/e2e/app_lifecycle_test.go (1)
92-93: Minor readability tweak: avoidctxshadowing in cleanup.Consider renaming the local timeout context to
stopCtxto keep it visually distinct from the outer test context.Suggested small rename
- ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + stopCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() - Expect(srv.Stop(ctx)).To(Succeed()) + Expect(srv.Stop(stopCtx)).To(Succeed())🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/e2e/app_lifecycle_test.go` around lines 92 - 93, Rename the local timeout context used in the cleanup block to avoid shadowing the outer test context: change the call context.WithTimeout(context.Background(), 30*time.Second) so its returned context variable is named stopCtx (and the cancel function stopCancel), and update the defer to defer stopCancel() everywhere; this removes the inner variable named ctx and prevents shadowing of the outer ctx used elsewhere in the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/e2e/app_lifecycle_test.go`:
- Around line 92-93: Rename the local timeout context used in the cleanup block
to avoid shadowing the outer test context: change the call
context.WithTimeout(context.Background(), 30*time.Second) so its returned
context variable is named stopCtx (and the cancel function stopCancel), and
update the defer to defer stopCancel() everywhere; this removes the inner
variable named ctx and prevents shadowing of the outer ctx used elsewhere in the
test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 706409b2-18d4-4388-81cf-c2a207140d33
📒 Files selected for processing (1)
test/e2e/app_lifecycle_test.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1286 +/- ##
==========================================
- Coverage 79.39% 79.35% -0.05%
==========================================
Files 205 205
Lines 10998 10998
==========================================
- Hits 8732 8727 -5
- Misses 1564 1574 +10
+ Partials 702 697 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
app_lifecycle_test.go"when restarting the service" test that still fails on main despite fix: use context.Background() for service restart in lifecycle test #1276DeferNewin go-libs registers aDeferCleanupwith a 10-second timeout, but the fx default stop timeout is 15 seconds — under CI load the full shutdown chain (watermill router, nats subscriber/connection, circuit breaker, etc.) can exceed 10sDeferCleanupwith a 30-second budget that runs beforeDeferNew's cleanup (Ginkgo LIFO order), making the latter a no-op (cancel == nil)Test plan
🤖 Generated with Claude Code