graphql-subscriptions icon indicating copy to clipboard operation
graphql-subscriptions copied to clipboard

Better error should be thrown if subscription ID is invalid

Open OmgImAlexis opened this issue 2 years ago • 0 comments

When passing in an invalid ID such as 0 to Pubsub.unsubscribe() it will throw with an unhelpful error.

TypeError: Cannot read property '0' of undefined
    at PubSub.unsubscribe (/usr/local/bin/api/node_modules/graphql-subscriptions/dist/pubsub.js:40:61)
    at /usr/local/bin/api/dist/index.js:34948:22
    at Timeout._onTimeout (/usr/local/bin/api/dist/index.js:19003:29)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

https://github.com/apollographql/graphql-subscriptions/blob/d8bfcae8488747a868b171e47542e17a0bd9f42f/src/pubsub.ts#L33-L37

OmgImAlexis avatar May 23 '22 21:05 OmgImAlexis