Skip to content

Conversation

EmrysMyrddin
Copy link
Collaborator

@EmrysMyrddin EmrysMyrddin commented Aug 11, 2025

HTTP transport loading is causing infinite loop when subscriptions option is provided with the http kind (or if kind is not specified since it defaults to http).

This is caused by the fact we pass all parent transport entry options to the subscription specific transport. In the case of the http transport, it was causing an infinite loop since a new subscriptions specific transport was instanciated every time because subscriptions option was always present.

This PR fixes this by explicitly removing the subscriptions attribute from the options passed to the subscription transport builder.

Related to #1379

@Copilot Copilot AI review requested due to automatic review settings August 11, 2025 20:18
Copy link
Contributor

@Copilot Copilot AI left a comment

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 fixes an infinite loop bug in the HTTP transport when handling GraphQL subscriptions. The issue occurred when the subscriptions option was passed to the subscription transport builder, causing recursive instantiation.

  • Removes the subscriptions attribute from options passed to subscription transport
  • Adds explanatory comments for the fix
  • Prevents infinite recursion in HTTP transport subscription handling

Comment on lines 107 to 113
options: {
...payload.transportEntry.options,
...payload.transportEntry.options?.subscriptions?.options,
// Make sure to remove subscription option to avoid infinite loop.
// This option doesn't make sense here but is present in `transportEntry.options`
subscriptions: undefined,
},
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Instead of setting subscriptions: undefined, consider using object destructuring with rest operator to exclude the subscriptions property entirely. This would be more explicit: const { subscriptions, ...optionsWithoutSubscriptions } = payload.transportEntry.options; options: { ...optionsWithoutSubscriptions, ...payload.transportEntry.options?.subscriptions?.options }

Suggested change
options: {
...payload.transportEntry.options,
...payload.transportEntry.options?.subscriptions?.options,
// Make sure to remove subscription option to avoid infinite loop.
// This option doesn't make sense here but is present in `transportEntry.options`
subscriptions: undefined,
},
options: (() => {
const { subscriptions, ...optionsWithoutSubscriptions } = payload.transportEntry.options ?? {};
return {
...optionsWithoutSubscriptions,
...payload.transportEntry.options?.subscriptions?.options,
};
})(),

Copilot uses AI. Check for mistakes.

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-mesh/fusion-runtime 0.11.20-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 1.16.3-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/logger-json 0.0.7-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/logger-pino 1.0.3-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/logger-winston 1.0.4-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 1.0.22-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-aws-sigv4 1.0.18-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-deduplicate-request 1.0.4-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/hmac-upstream-signature 1.2.31-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-jwt-auth 1.5.8-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-opentelemetry 1.3.66-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 1.3.54-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 1.10.3-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-common 0.7.38-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http 0.7.2-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http-callback 0.7.2-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-ws 1.1.2-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Binary for Linux-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:1.16.3-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 11, 2025

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:1.16.3-alpha-08c27dc7bbdeb05b6399827ceb8ef259cd41aa3a-bun

Copy link
Member

@ardatan ardatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but should we also cover this usecase in our tests?

@EmrysMyrddin
Copy link
Collaborator Author

Yeah I will try to add a unit test

@EmrysMyrddin EmrysMyrddin force-pushed the fix/1379-http-subscription-options-infinite-loop branch from 3af9992 to a6c5fed Compare August 14, 2025 18:56
@EmrysMyrddin EmrysMyrddin merged commit 34294ea into main Aug 14, 2025
67 checks passed
@EmrysMyrddin EmrysMyrddin deleted the fix/1379-http-subscription-options-infinite-loop branch August 14, 2025 19:15
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