72 Commits
Author SHA1 Message Date
Florian Reinhart 6cd94faa1a Add option to enable logging in http2 module 2016-11-12 14:37:55 +01:00
Florian Reinhart 4f1786bccd Add option to enable logging in http2 module 2016-11-12 13:51:35 +01:00
Florian Reinhart 5f10cf5f97 Add separate logger for each component 2016-11-12 10:48:18 +01:00
Florian Reinhart fac48d95a4 Fix deprecation warnings for Buffer 2016-11-02 11:14:37 +01:00
Andrew Naylor fd922fb2d8 Fix Codacy Code Style issues 2016-09-25 20:31:06 +01:00
Andrew Naylor a23b5f2985 Ensure we reset the failure count
If we don't reset the failure count then the pending notification queue
will stall without warning. Instead it seems fair that if the
application continues to send notifications then we give it another
shot and attempt 3 more times.

This has the effect of never really "hard" failing but all notifications
are handled and the application can take responsibility for abandoning
the worker if they are monitoring the errors correctly.
2016-09-21 22:23:05 +01:00
Andrew Naylor 8b5ae992ff Fix Codacy issues 2016-09-21 10:29:07 +01:00
Andrew Naylor 0e01d49ba9 Handle GOAWAY events 2016-09-21 01:59:27 +01:00
Andrew Naylor fe3b8352ad Ensure that end gets bubbled
Otherwise endpointManager might not continue sending
2016-09-21 01:04:33 +01:00
Andrew Naylor 7a3d3f48ea Wait until close to trigger stream errors 2016-09-21 01:04:14 +01:00
Andrew Naylor cdb689a1f4 Handle errors from all HTTP/2 components
Because we don't `throw` the resulting message we don't need to
package it in an error. It will be wrapped in a VError accordingly.
2016-09-21 00:31:47 +01:00
Andrew Naylor 1e81a7d1cd Ensure we convert connection errors to an Error
It normally emits strings which is bad but we can deal with it. The
Promises wouldn't be happy otherwise.
2016-09-20 21:44:55 +01:00
Andrew Naylor 4fedc00742 Propagate errors to pending streams 2016-09-20 12:15:09 +01:00
Andrew Naylor 518eeacbe5 Ensure the stream is allocated an ID
We need to ensure a stream has entered the `_streamIds` array so we can
loop over it if an error occurs.

If an error occurs we need to clean up old streams by bubbling the error
through to them, allowing their corresponding promise to be rejected. If
the error doesn't make it through the promise will stall forever.

An error occurring between a stream being created (popping it from the
client queue) and having data written (when it would normally be
allocated an ID) then it can end up in limbo because looping through
`streamIds` would not hit that stream.
2016-09-20 11:45:18 +01:00
Andrew Naylor 7c9cac7706 Ensure we can establish new connections in wakeup 2016-09-19 18:44:46 +01:00
Andrew Naylor 643b0946e2 Ensure that errors trigger a wakeup 2016-09-19 17:00:36 +01:00
Andrew Naylor 79b9cb00de Only count connection failures with no established 2016-09-19 15:18:47 +01:00
Andrew Naylor 196e56062d Wakeup endpoint manager when connection ends 2016-09-18 19:14:57 +01:00
Andrew Naylor a28b460f79 Ensure new connections aren't established at limit 2016-09-18 19:10:18 +01:00
Andrew Naylor 985aec3f53 Always emit wakeup
We may need to depend on `wakeup` in Client to cleanup pending
notifications if all connections fail
2016-09-18 18:02:35 +01:00
Andrew Naylor 2e5472f4fb Wrap endpoint errors before passing them on 2016-09-06 08:40:26 +01:00
Andrew Naylor a857c8894c Fix codacy style issues 2016-08-09 21:14:46 +01:00
Andrew Naylor 0d2b686e3d Ensure that pending connections are closed 2016-08-09 21:09:44 +01:00
Andrew Naylor 85f4eb2c92 Implement shutdown 2016-08-09 20:43:43 +01:00
Andrew Naylor ea0ef5f6d5 Break out the endpoint cleanup 2016-06-26 01:13:47 +01:00
Andrew Naylor 4f25e5ce98 Fix a codacy issue 2016-06-26 01:06:28 +01:00
Andrew Naylor c0b0874de0 Ensure only pre-connect errors are failures 2016-06-25 19:18:32 +01:00
Andrew Naylor 69920ae2ff Ensure we don't stomp on pending connections 2016-06-25 19:14:29 +01:00
Andrew Naylor c0337c4c4d Ensure an errored connection is not used 2016-06-25 18:56:46 +01:00
Andrew Naylor 46c9213afd Ensure ended sockets are cleaned up 2016-06-25 17:37:56 +01:00
Andrew Naylor e439601dd9 Simplify the index arithmetic 2016-06-17 13:29:06 +02:00
Andrew Naylor 70f6fc029d Implement round-robin connections 2016-06-03 19:16:43 +01:00
Andrew Naylor b30bb49ab5 Enforce maxConnections limit 2016-05-31 08:41:01 +01:00
Andrew Naylor c836908329 Reinstate connectionRetryLimit 2016-05-31 08:32:06 +01:00
Andrew Naylor 7ea81fc0e6 Establish multiple connections 2016-05-30 16:55:21 +01:00
Andrew Naylor 9c38768019 Reset the failure count after success 2016-05-30 16:19:07 +01:00
Andrew Naylor 13898f05ee Error-out on multiple connection failure 2016-05-30 15:48:08 +01:00
Andrew Naylor 4c9586fbdc Destroy the socket when error occurs 2016-05-30 01:02:30 +01:00
Andrew Naylor 1b81eb9394 Retab the project 2016-05-30 01:02:19 +01:00
Andrew Naylor 1079095458 Null-out the retain-cycle 2016-05-01 23:55:26 +01:00
Andrew Naylor 08781d0fa3 Improve code coverage and use "bunyan" properly 2016-05-01 15:35:52 +01:00
Andrew Naylor e87f326829 Fix some more codacy issues 2016-04-18 09:56:33 +01:00
Andrew Naylor 07d6782899 Fix code style problems 2016-04-17 20:09:32 +01:00
Andrew Naylor 61be597fc2 Simplify the wakeup behaviour also 2016-03-28 02:28:55 +01:00
Andrew Naylor 51c5fba96c Manage the stream counts within Endpoint
Using the built-in available stream count was not suitable as it is
managed on a different schedule to that which we require. `createStream`
would not increment he used stream count until a frame was actually sent
whereas we want to identify a stream as in-use as soon as it is acquired
so we shall maange a local count.
2016-03-28 02:19:06 +01:00
Andrew Naylor 635e9f54e1 Send the prelude before TLS establishes
This simplifies both the code and the tests.
2016-03-21 00:33:55 +00:00
Andrew Naylor ee7a5227b9 Protect against re-entrancy for wakeup 2016-03-20 16:00:55 +00:00
Andrew Naylor 1400023e89 Prevent wakeup being emitted on connect.
We know that APNS will send a stream limit immediately after connection
and given the current state of node-http2 we have to start with an
initial stream limit of 0 until that comes through. As such it is
redundant to emit wakeup immediately after connection because we won't
be able to do anything.

In addition, if we do go back to having an infinite stream limit
initially we don't want to flood a single endpoint with streams when we
could distribute it across multiple. (Imagine a call to
`pushNotification` with 10,000 tokens all piling onto a single
connection).
2016-03-13 22:32:24 +00:00
Andrew Naylor c5e0640be3 Correct the availableStreamSlots logic
The streamSlotsFree logic within connection is broken with the Infinity
value. As we know that APNS will always set a stream limit on connect we
set the values to 0 immediately and allow the incoming SETTINGS frame to
update and begin the process.
2016-03-13 21:36:46 +00:00
Andrew Naylor 932c517fda Ensure the HTTP/2 machinery is setup after connect 2016-03-13 15:02:32 +00:00