fix(fcm): Wrap HTTP/2 session errors in promise by jonathanedey · Pull Request #2868 · firebase/firebase-admin-node

@jonathanedey

RELEASE NOTE: Fixed a issue which caused session errors not to be thrown.

  • Promise wrapped HTTP/2 session errors allowing them to be caught as a FirebaseMessagingSessionError
  • Added pendingBatchResponse field to new FirebaseMessagingSessionError to allow access to the status of messages which were in flight at error time.

github-advanced-security[bot]

@jonathanedey

@jonathanedey

lahirumaramba

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jonathan! Added one comment

// Start session listeners
http2SessionHandler.invoke().catch((error) => {
const pendingBatchResponse =
sendResponsePromise ? sendResponsePromise.then(this.parseSendResponses) : undefined;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking out loud, if a session error occurs before any of the requests have gone through would pendingBatchResponse be undefined?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this would be undefined.

@jonathanedey