mirror of
https://github.com/expo/node-apn.git
synced 2026-11-15 08:58:07 -10:00
APNs sends GOAWAY frames when it decides to terminate a connection (see "Terminating an APNs Connection" at https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html). Node then closes the HTTP/2 session and all streams (requests) associated with that session end prematurely, triggering errors like `"stream ended unexpectedly"`. This commit adds support for handling GOAWAY frames. The "goaway" event includes a stream ID, which denotes the last successfully processed stream; that is, all later streams are invalid. The APNs documentation also says the GOAWAY frame includes JSON data that contains a `reason` key describing the error, which should prove useful for diagnosing errors due to GOAWAY frames.