Skip to content

Restore current multiplex after nested execution - #5714

Merged
rmosolgo merged 1 commit into
rmosolgo:masterfrom
ydah:restore-current-multiplex-after-nested-execution
Aug 27, 2026
Merged

Restore current multiplex after nested execution#5714
rmosolgo merged 1 commit into
rmosolgo:masterfrom
ydah:restore-current-multiplex-after-nested-execution

Conversation

@ydah

@ydah ydah commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Nested GraphQL execution currently clears the outer execution's fiber-local multiplex.

This can happen when a resolver executes another schema, for example while triggering subscriptions or composing an internal GraphQL API:

before = GraphQL::Current.operation_name
InnerSchema.execute("{ value }")
after = GraphQL::Current.operation_name

before # => "OuterOperation"
after  # => nil

Both GraphQL::Execution::Interpreter and GraphQL::Execution::Runner replace Fiber[:__graphql_current_multiplex] when execution starts, then unconditionally set it to nil in ensure. As a result, the outer multiplex is lost after the nested query finishes.

Besides breaking GraphQL::Current.operation_name, this can cause later dataloader runs to lose their current trace because they read it from the same fiber-local multiplex.

This PR saves the previous multiplex before starting execution and restores it in ensure. Top-level execution continues to restore nil, while nested execution returns to the outer multiplex.

@rmosolgo rmosolgo added this to the 2.6.10 milestone Aug 27, 2026
@rmosolgo

Copy link
Copy Markdown
Owner

Thanks for this fix!

@rmosolgo
rmosolgo merged commit a345858 into rmosolgo:master Aug 27, 2026
12 of 15 checks passed
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