Skip to content

Terminating subscriptions not working on initial step #1050

@Zhenya750

Description

@Zhenya750

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions