-
Notifications
You must be signed in to change notification settings - Fork 13
No error when exceeding message limit #4
Comments
Did the callback not occur with an error status code? https://github.com/pusher/pusher-node-server/blob/master/lib/pusher.js#L52 There's a test in place to check this: Please let me know if this doesn't work as expected. |
When I noticed that some messages were dropped, I added this code directly in production (the documentation doesn't mention the callback anymore and I wasn't sure what was causing the issue): pusher.trigger(privateRoom, eventName, message, null, function (err) {
if (err)
console.error('pusher error on', eventName, err);
}); Without seeing anything in the console. After thinking about it, it seems that |
That would make sense since a 413 is not an error code. Couple of options here:
@mloughran @mdpye What do you guys think? |
IMO, updating the README to warn about the 10Kb limit and the format of the answer is enough. There's no need to introduce a breaking change for that. |
I'm not familiar with the code, but HTTP 413 is absolutely an error and the POST request has failed. We should deal with that in the same way we might a 400 or 403 |
The request hasn't failed hasn't errored, which may be what the I tried adding a test:
And the Could try testing adding test which would result in a 400 from the API and see if the error object is populated. |
The reason why this was puzzling to me was that when a call a module, I expect it to pass an error to my callback if my request is unsuccessful. That the error comes from a hanged TCP socket or an HTTP status is an implementation detail to me. The current behavior should be documented because it's not most common node.js modules behave. From the back of my head, here are modules that use an internal HTTP request, yet pass errors to callback when they get 4XX statuses: felix-couchdb, node-mongodb, hipchat, twitter and oauth. Now, there's nothing wrong with the current behavior, but having the documentation stress that the callback passes a HTTP response would have saved me a couple of hours of bug hunting. |
In general, I agree with @lperrin. The library wraps an API, the HTTP transport of which shouldn't leak into the distinction between transport and application errors. Ideally, all non-200 status codes should be translated to an error in the callback, because the API semantics specify that they are errors. However, that is a large change to the current behaviour and I'm not going to dive into it now. In the mean time, how about f59dd1e |
The Pusher limits messages to 10Kb. This is perfectly fine, but the driver silently fails in this case. Having messages randomly disappear was quite puzzling for us :)
The text was updated successfully, but these errors were encountered: