Repository navigation
test(hangfire): use thread-safe Hangfire.InMemory storage in tests - #5905
Merged
Merged
Conversation
Hangfire.MemoryStorage's monitoring API enumerates job state lists while the server is writing them, which made WaitForJob throw "Collection was modified". Hangfire.InMemory returns history newest-first, so read History[0]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5905 +/- ##
==========================================
+ Coverage 76.86% 76.87% +0.01%
==========================================
Files 533 533
Lines 19847 19847
Branches 3920 3920
==========================================
+ Hits 15256 15258 +2
+ Misses 3710 3709 -1
+ Partials 881 880 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the flaky
HangfireTestsfailureInvalidOperationException: Collection was modifiedthrown fromHangfire.MemoryStorage'sMemoryStorageMonitoringApi.JobDetails.HangfireFixture.WaitForJobpolls that API while theBackgroundJobServerworker is updating the same job, and MemoryStorage isn't safe for that.The test project now uses the official, thread-safe
Hangfire.InMemorystorage (UseInMemoryStorage()) instead of the communityHangfire.MemoryStoragepackage.Hangfire.InMemoryreturnsJobDetailsDto.Historynewest-first (like the SQL Server storage), whereas MemoryStorage returned it oldest-first, so the fixture now reads the current state fromHistory[0].Test-only change;
Sentry.Hangfireitself is untouched.Closes #5904
#skip-changelog
🤖 Generated with Claude Code