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
I was trying to use subscriptions (graphql-ws) and found a little problem on initial step: when
p.handleInit()returns error thenengine.TerminateAllSubscriptions()does nothing, because at this momentengine.subCancellationsis empty, so it returns nil error toUniversalProtocolHandler.Handle(), and subscription keeps alive.(element is added to
engine.subCancellationsonly on start step, not initial).(link to this func)
I suppose we should return error instead of terminating all subscriptioins