apollographql / graphql-subscriptions

:newspaper: A small module that implements GraphQL subscriptions for Node.js
MIT License
1.58k stars 133 forks source link

Better error should be thrown if subscription ID is invalid #257

Open OmgImAlexis opened 2 years ago

OmgImAlexis commented 2 years ago

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