pusher/pusher-js

Gateway 504 error and how to handle it gracefully

Closed this issue · 2 comments

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
Application crashes due to current outage (504 Gateway Timeout), which causes the application to crash. I am looking to figure out how to best handle this gracefully.

The call in question is using pusherjs - url: 'https://api-eu.pusher.com/apps/x/events?auth_key=y&auth_timestamp=1699977069&auth_version=1.0&body_md5=z&auth_signature=z'

If the current behavior is a bug, please provide the steps to reproduce and
if possible a minimal demo of the problem via https://jsfiddle.net or similar.

What is the expected behavior?
Gracefully handle outages in Pushers services

Which versions of Pusher, and which browsers / OS are affected by this issue?
Did this work in previous versions of Pusher? If so, which?

Node.js-based application

Are you able to use the result of the promise returned by the API request to determine the error and handle accordingly?
https://github.com/pusher/pusher-http-node?tab=readme-ov-file#api-requests

For example

function triggerEvent() {
    pusher.trigger("private-channel", "my-event", {
        message: "hello world"
    }).then(response => {
        console.log(`message sent, ${response.statusText}` )
    }).catch(e => {
        console.log(e)
        setTimeout(() => {
            console.log("retrying without crash")
            triggerEvent();
        }, 5000);
        
    });
}

We haven't had a response here so closing this. Please get in touch with us at support@pusher.com if you need further support.