apollographql / apollographql/graphql-subscriptions
Better error should be thrown if subscription ID is invalid
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
When passing in an invalid ID such as `0` to `Pubsub.unsubscribe()` it will throw with an unhelpful error.
```ts
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
Contributor guide
Research direction
Start in src/pubsub.ts at the unsubscribe implementation referenced by the issue, and inspect how an invalid subscription ID reaches the reported TypeError. The change is complete when passing an invalid ID such as 0 produces a helpful, intentional error instead of the unhelpful property-access failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100