Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "pusher:subscription_error" event #177

Closed
tillkruss opened this issue Mar 23, 2018 · 8 comments · Fixed by #284
Closed

Support "pusher:subscription_error" event #177

tillkruss opened this issue Mar 23, 2018 · 8 comments · Fixed by #284

Comments

@tillkruss
Copy link
Contributor

Support for pusher:subscription_error would be nice. It only applied to private and presence channels.

pusher:subscription_succeeded could be moved to basic pusher channel, because it's triggered for all channel types.

https://pusher.com/docs/client_api_guide/client_events#subscription_error

@driesvints
Copy link
Member

How would this exactly work? Something like an .error() method? Can't you simply catch these errors in your code?

@charleswolfe
Copy link

I could see subscription errors coming back in firefoxes console. I wanted to be able to execute a function when the subscription failed.

I prefer something like 'subscription_error', however 'error' would be fine if there was a type for 'subscription_error', so I handle that very specific case.

Also thanks for looking into this @driesvints , knowing that we didn't make the socket connection and being able to handle it allows us to write less code. For example: dealing with a user that logs in to an application simultaneously using multiple browsers.

@tillkruss
Copy link
Contributor Author

tillkruss commented Oct 31, 2018

@driesvints: I guess I'd like to handle errors in a callback and if there is no callback maybe rethrow the exception or just call console.error().

Echo.join(`chat.${roomId}`)
    .here(...)
    .joining(...)
    .leaving(...)
    .listen('NewMessage', ...)
    .subscriptionError(err => {
        // Sentry.captureException(err);
    });

@driesvints
Copy link
Member

Is there a way to do a type check on the error? Something like this:

Echo.join(`chat.${roomId}`)
    .here(...)
    .joining(...)
    .leaving(...)
    .listen('NewMessage', ...)
    .error(err => {
        if (err.type === 'subscription') {
             // do whatever type related
        }
        
        // Sentry.captureException(err);
    });

Reason why I want to do it this way is to just provide a generic way of catching errors so people can do whatever they want.

@tillkruss
Copy link
Contributor Author

That'd be great.

Echo.join(`chat.${roomId}`)
    .here(...)
    .joining(...)
    .leaving(...)
    .listen('NewMessage', ...)
    .error((err, type) => {
        // type = subscription
        // err = Error object
    });

@driesvints
Copy link
Member

Okay so I don't know when I'll have time to work on this but feel free to send in a PR if you get to it before me.

@driesvints
Copy link
Member

Sent a PR for this here: #284

@tillkruss would be great if you could give feedback on my notes on the private channel thing on the PR.

@tillkruss
Copy link
Contributor Author

@driesvints: LGTM. Haven't tested it, I don't think we use that code anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants