Skip to content

Fix background worker to run only onces. While loop should be user ha… - #24

Merged
TopSwagCode merged 1 commit into
masterfrom
bugfix/backgroundworker-runs-once
Jan 31, 2026
Merged

TopSwagCode merged 1 commit into
masterfrom
bugfix/backgroundworker-runs-once

Conversation

@TopSwagCode

Copy link
Copy Markdown
Owner

…ndled

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.95%. Comparing base (ea7c494) to head (42439b1).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #24   +/-   ##
=======================================
  Coverage   77.95%   77.95%           
=======================================
  Files           2        2           
  Lines         186      186           
  Branches       28       28           
=======================================
  Hits          145      145           
  Misses         21       21           
  Partials       20       20           
Flag Coverage Δ
unittests 77.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI 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.

Pull request overview

This PR implements a significant behavioral change to continuous background workers, changing them from running in an infinite loop to executing exactly once. The responsibility for implementing loops is now explicitly shifted to the user.

Changes:

  • Removed automatic while loop from continuous worker code generation, making workers execute only once
  • Removed iteration tracking since continuous workers no longer iterate automatically
  • Updated all tests to expect single execution behavior instead of multiple iterations
  • Added new documentation file (CLAUDE.md) explaining the architecture and the explicit pattern for continuous workers

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/MinimalWorker.Generators/WorkerEmitter.cs Removed the automatic while (!token.IsCancellationRequested) loop from continuous worker generation, removed iteration tracking, and simplified telemetry/logging to reflect single-execution behavior
test/MinimalWorker.Test/TelemetryTests.cs Updated all telemetry tests to expect single execution, removed iteration assertions, and added signal mechanism to gauge test to measure worker while running
test/MinimalWorker.Test/ServiceResolutionTests.cs Updated all service resolution tests to expect exactly one execution instead of multiple iterations
test/MinimalWorker.Test/ScopingTests.cs Updated scoping tests to verify continuous workers use a single scope for their single execution
test/MinimalWorker.Test/MultiFileWorkerTests.cs Updated multi-file worker tests to expect single execution per worker
test/MinimalWorker.Test/ErrorHandlerTests.cs Simplified error handling tests to expect single execution and single exception instead of multiple iterations
test/MinimalWorker.Test/ContinuousWorkerTests.cs Added new test explicitly verifying single execution, updated all existing tests to expect once-only behavior, and removed delays that were previously needed for multiple iterations
test/MinimalWorker.Test/BuilderPatternTests.cs Removed unnecessary delay from test since worker now executes only once
CLAUDE.md New documentation file explaining architecture, worker behavior, testing patterns, and explicitly stating that continuous workers run exactly once and users must implement their own loops

Comment thread test/MinimalWorker.Test/TelemetryTests.cs
Comment thread test/MinimalWorker.Test/TelemetryTests.cs
@TopSwagCode
TopSwagCode merged commit 3fedf59 into master Jan 31, 2026
13 checks passed
@TopSwagCode
TopSwagCode deleted the bugfix/backgroundworker-runs-once branch January 31, 2026 15:36
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.

3 participants