OneSignal-Website-SDK icon indicating copy to clipboard operation
OneSignal-Website-SDK copied to clipboard

Failures of Webhook causes confirmed deliverers to be skipped, possibly other logic

Open jkasten2 opened this issue 2 years ago • 0 comments

Description

One Line Summary

When a notification is received a network call is first made to the user configured Webhook. If it fails, the confirmed deliverer is skipped due to an unhandled exception.

Details

In the OneSignal ServiceWorker we kick off a network call to the user configured Webhook. If executeWebhooks is successful we then make a call to sendConfirmedDelivery. However sendConfirmedDelivery should not depend on executeWebhooks what so ever. https://github.com/OneSignal/OneSignal-Website-SDK/blob/151508/src/service-worker/ServiceWorker.ts#L270-L271

Steps to Reproduce Issue

  1. Ensure your app has OneSignal Confirmed Deliveries and is enabled.
  2. Configure OneSignal to use a Webhook, one that doesn't exists or returns 5xx errors.
  3. Open the "Network" tab in Chrome on the domain.
    • So we can observer the following steps.
  4. Send a notification
  5. Observe the expected failed webhook call
  6. Observe that a call to https://onesignal.com/api/v1/notifications/{notification_id}/report_received is never made when it should

Suggested Changes

Solutions

Both sendConfirmedDelivery and executeWebhooks should be executed in parallel and never throw due to a network call failure.

Related Changes

Recommend that we also use the same random 0 - 25 second delay that sendConfirmedDelivery does to cut down on spiking server load for Webhook as well. Since this secondary change is minimal, recommending to be done together as the same code flow will be tested.

jkasten2 avatar Oct 14 '21 19:10 jkasten2