Meteor-Community-Packages / Meteor-Community-Packages/raix-push
Unhandled exception when connection times out
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 505
- Forks
- 191
- PR merge metrics
- No merged PRs in 30d
Description
I noticed that an unhandled exception is raised when a connection to an APN is started (to send notifications to apple devices) but the connection times out. The following error is raised:
```
throw e;
^
Error: Connect timed out
at Connection. (/home/flavio/.meteor/packages/raix_push/.3.0.2.1ojwzxu++os+web.browser+web.cordova/npm/node_modules/apn/lib/connection.js:193:36)
at Timer.listOnTimeout [as ontimeout] (timers.js:121:15)
```
and then the whole application crashes.
A quick way to reproduce this is to drop all tcp connections to outbound port 2195 via iptables on the test machine and then trying to send a notification to an apple device.
As a workaround i found that adding an event listener for the `error` event correctly fixes the problem. I'm talking about adding [here](https://github.com/raix/push/blob/8f54dbfae705584a621defc91e1c8dbf9f9a41b1/lib/server/push.api.js#L126) the following code:
```
apnConnection.on('error', function (err) {
console.log('got error: ', err);
// maybe some cleanup code here?
});
```
just like it is done for the `transmissionError` two lines below in the very same file.
What do you think?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect lib/server/push.api.js around line 126 and compare the existing transmissionError handling nearby. Reproduce the timeout by blocking outbound port 2195 with iptables, then verify that sending a notification no longer crashes the application when the APN connection times out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100