-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when Pushover API responds with HTML #25
Comments
I have had the same problem twice today: |
Sure, I'm at least not expecting their service to have 100% uptime, but the library should not crash on a 5xx response. I just forked this and added some defensive try/catching in hopes that this stops the crash https://github.com/sulkaharo/node-pushover |
Made a PR to wrap the crashing JSON conversion #26 |
Thanks! I have requested a slight change. I will publish a new version once that is resolved (it's a trivial change, so if I don't hear back later today I will just add it and publish anyway :D)! |
Hello, it looks like there is another case related to this issue that brings down the application.
With the latest code (v1.2.1):
IMHO, more in general to have the Pushover.prototype.errors() throw means that it would be necessary to encapsulate every piece of code that is making use of that function in a P.S.: I've managed to see the result of the API that generates the crash:
I'm still way below the cap therefore it's probably an overload issue on the API side.
|
@jonasgroendahl or @xtvdata would either of you be able to share a snippet of how you are triggering this? Is it just 5 requests fired off at the same time? |
yes basically 5 requests or so at the same time will trigger a crash of node. doesn't matter if i include image or not. |
can you guys test 2f2fcb6 ? It works in my tests (trying to fix travis but it doesn't like my tokens) |
Pushed 1.2.2. |
Still having an error with latest version:
If I may, I’d suggest, in case of return status 429 from the API server, to throw or return (via callback) a specific error so that either this module or the application code can manage this specific error code with a delayed retry (otherwise the notification would be lost). Moreover, in case of implementing delayed retries in the module, I’d also suggest to set the notification date-time in order to keep the right timestamp on the notification even if it has been delayed. Anyway the main point is that, since the instance method |
Are you setting onerror to a function? That error suggests you are not. Here is a snippet from my test where it's being set:
|
Indeed that was generated by a missing function in my test case. Here is a practical use case, in which (if I'm not mistaken) the current behavior would make the case difficult to manage.
|
@qbit ping - can you please change the Pushover object creation to mandate the onerror setting. The way the current release works is, if an error happens and onerror is not defined, the app will crash due to trying to call an undefined function. Related, the documentation for the library indicates the function is optional, but it's not really. :) |
I just had an app crash and the stack trace indicates the issue is with the node-pushover library not handling the API not responding with a JSON object. Add some defensive code somewhere to check if the response actually parses as JSON? :)
The text was updated successfully, but these errors were encountered: