Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminating subscriptions not working on initial step #1050

Open
Zhenya750 opened this issue Jan 30, 2025 · 0 comments
Open

Terminating subscriptions not working on initial step #1050

Zhenya750 opened this issue Jan 30, 2025 · 0 comments
Assignees
Labels
internally-reviewed Internally reviewed

Comments

@Zhenya750
Copy link

Zhenya750 commented Jan 30, 2025

I was trying to use subscriptions (graphql-ws) and found a little problem on initial step: when p.handleInit() returns error then engine.TerminateAllSubscriptions() does nothing, because at this moment engine.subCancellations is empty, so it returns nil error to UniversalProtocolHandler.Handle(), and subscription keeps alive.

(element is added to engine.subCancellations only on start step, not initial).

(link to this func)

func (p *ProtocolGraphQLWSHandler) Handle(ctx context.Context, engine subscription.Engine, data []byte) error {
	...
	switch message.Type {
	case GraphQLWSMessageTypeConnectionInit:
		ctx, err = p.handleInit(ctx, message.Payload)
		if err != nil {
                        ...
			return engine.TerminateAllSubscriptions(&p.writeEventHandler)
		}

		...
	case GraphQLWSMessageTypeStart:
		return engine.StartOperation(ctx, message.Id, message.Payload, &p.writeEventHandler)
	...
	}

	return nil
}

I suppose we should return error instead of terminating all subscriptioins

@alepane21 alepane21 added the internally-reviewed Internally reviewed label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internally-reviewed Internally reviewed
Projects
None yet
Development

No branches or pull requests

3 participants