Repository navigation
Fix ResultDocument.IsNullOrInvalidated missing invalidated objects behind a field reference - #175
Open
michaelstaib wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The test pool skips ResolverTask.Reset(), allowing WaitUntilAllReturnedAsync() to pass while operation-context task counts remain outstanding and leaving the full task-release lifecycle unverified.
1 open issue
What changed in this PR
Fixes detection of invalidated objects behind field references in GraphQL results. Building on #138’s task-release work, this prevents duplicate null violations and releases buffered child resolvers that cannot contribute to the result.
Changes:
- Resolve field references before checking object invalidation flags.
- Update resolver, batch, and pure completion paths to handle already-invalidated objects.
- Add regression tests for reference detection, skipped child resolvers, and task-pool balance.
| File | Description |
|---|---|
src/HotChocolate/Core/test/Types.Tests/Text/Json/ResultDocumentInvalidationTests.cs |
Tests references to live and invalidated objects. |
src/HotChocolate/Core/test/Execution.Tests/NonNullInvalidatedObjectTests.cs |
Tests results, skipped child execution, and task returns across completion paths. |
src/HotChocolate/Core/src/Types/Text/Json/ResultDocument.cs |
Checks invalidation flags on the referenced object. |
src/HotChocolate/Core/src/Types/Execution/Processing/Tasks/ResolverTaskFactory.cs |
Releases invalidated objects’ buffered children during pure completion. |
src/HotChocolate/Core/src/Types/Execution/Processing/Tasks/ResolverTask.CompleteValue.cs |
Avoids duplicate null handling while releasing dropped child tasks. |
src/HotChocolate/Core/src/Types/Execution/Processing/Tasks/BatchResolverTask.cs |
Applies the same invalidation handling to batch completion. |
Review effort: Balanced
|
|
||
| public override void Return(ResolverTask obj) | ||
| { | ||
| if (Interlocked.Decrement(ref _outstanding) == 0) |
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.

ResultDocument.IsNullOrInvalidatedreturned false for an invalidated object reached through a field reference. It resolved the reference when it read the token type, but then read the flags of the reference row, and invalidation only flags the object row. Callers treated the invalidated object as live data.Changes:
IsNullOrInvalidatedreads the raw token, follows a reference to its object row and checks that row's flags.Stacked on #138.
Tests:
ResultDocumentInvalidationTestscover a field reference to an invalidated and to a live object.NonNullInvalidatedObjectTestscover a pure child invalidating a resolved, a batch and a pure object: they snapshot the result, check that the slow child resolver never runs and that the resolver task pool is balanced. Execution.Tests and Types.Tests pass on net10.0, and the touched classes pass on net8.0.