Skip to content

馃悰 RelationConnection loads the same relation twice under AsyncDataloader (2.6.7) - #5685

Open
benschwarz wants to merge 1 commit into
rmosolgo:masterfrom
benschwarz:patch-1
Open

馃悰 RelationConnection loads the same relation twice under AsyncDataloader (2.6.7)#5685
benschwarz wants to merge 1 commit into
rmosolgo:masterfrom
benschwarz:patch-1

Conversation

@benschwarz

Copy link
Copy Markdown

Given a query like:

{ posts(first: 20) { edges { node { id } } pageInfo { endCursor } } }

Both fields call load_nodes. 2.6.7 runs them concurrently, earlier releases didn't.

@nodes ||= limited_nodes.to_a   # relation_connection.rb:224

Fiber one waits on the DB before setting @nodes. Fiber two sees empty and loads the same relation again. Whichever finishes first clears ActiveRecord's load state from under the other.

This results in:

NoMethodError: undefined method 'instantiate' for nil, plus a duplicate query on every paginated connection.

Refactor load_nodes method to improve node loading logic and handle concurrent access.
@rmosolgo

rmosolgo commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Hey, thanks for reporting this and sorry for the trouble 馃槚

I'm hesitant to address this with dataloader.yield because I expect this to all happen inside GraphQL-Ruby's execution steps -- without handing off to Dataloader to fetch results from Dataloader sources.

Do you have a guess why the Fiber is yielding here? Is this a custom connection implementation?

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.

2 participants