Skip to content

Catch ajax errors globally when server goes away or other errors occur #16392

Closed

Description

@PVince81

Whenever the following happens:

  • maintenance mode is enabled (HTTP 503)
  • server becomes unavailable (HTTP 503)
  • user is logged out (session expired)
  • server has intermittent connection issues (HTTP 400 or others)

if it happens during an ajax call, the error isn't always caught and processed properly, so the user might see strange behavior.

One idea would be to implement global ajax handlers using https://api.jquery.com/category/ajax/global-ajax-event-handlers/ and provide a default mechanism for when 503 is returned or whenever the user gets logged out.

It might not work for all apps, so apps might still need to do special handling in other cases.

@nickvergessen you had a ticket about the files app looping if I remember well ? Please link it here.

@butonic @blizzz did some preliminary work on catching errors

CC @LukasReschke FYI

Activity

  1. nickvergessen commented on May 18, 2015

    @nickvergessen
    Contributor

    Can not find the issue anymore, so maybe we just discussed it and never created it.

  2. oparoz commented on May 18, 2015

    @oparoz
    Contributor

    I agree. When uploading a new version of an app, I always have to check the network tab to see if I'm getting 503 errors because the app doesn't stop working when it gets them.

  3. added this to the milestone on Jun 5, 2015
  4. DeepDiver1975 commented on Sep 22, 2015

    @DeepDiver1975
    Contributor

    @PVince81 is there a solution at hand? Something we can fix for 8.2? or 9.0?

  5. PVince81 commented on Sep 28, 2015

    @PVince81
    ContributorAuthor

    @DeepDiver1975 the only solution I know of is what you implemented yourself: #16783

  6. ghost added this to the backlog milestone on Oct 5, 2015
  7. ghost removed this from the milestone on Oct 5, 2015
  8. butonic commented on Dec 9, 2015

    @butonic
    Contributor

    since #16783 is closed I am adding this to oc9 to test if shibboleth session timeouts are handled gracefully with tha webdav based approach. However, since ANY ajax call will be redirected I don't think it matters an we will need to reopen #16783 anyway ...

  9. modified the milestones: , backlog on Dec 9, 2015
  10. PVince81 commented on Dec 9, 2015

    @PVince81
    ContributorAuthor

    @butonic the current webdav approach will redirect if a 401 error is returned by the server.

  11. 8 remaining items

  12. PVince81 commented on Dec 10, 2015

    @PVince81
    ContributorAuthor
  13. PVince81 commented on Dec 10, 2015

    @PVince81
    ContributorAuthor

    This says it is impossible: http://stackoverflow.com/a/2573589

    But one trick proposed here http://stackoverflow.com/a/24715958 is that we set a specific custom header in ALL our ajax responses. Then if the jQuery ajax response doesn't contain it, then it means it was a redirect or not an ajax answer (but a plain page instead).

    This reminds me of the old topic about detecting whether we're getting a full page as a response by checking if Content-Type was JSON or XML: #15357 (or not 100% that)

  14. PVince81 commented on Dec 10, 2015

    @PVince81
    ContributorAuthor

    @butonic what page does a SSO fail redirects to ? ownCloud's login page ?
    There is also a suggest to add a special header on the login page's response. Then check for that response in the ajax response to find out if we just got the login page, and react accordingly (redirect to the real login page)

  15. DeepDiver1975 commented on Dec 10, 2015

    @DeepDiver1975
    Contributor

    @butonic what page does a SSO fail redirects to ? ownCloud's login page ?

    the redirect goes to the web page of the idp - a redirect to some url out there in the wild

  16. PVince81 commented on Dec 10, 2015

    @PVince81
    ContributorAuthor

    Hmmmm... and if that URL isn't in the same domain we might even get a cross-domain fail

  17. butonic commented on Dec 10, 2015

    @butonic
    Contributor

    @PVince81 yes, cors needs to be set in the config to allow ajax to the idp to make this detectable without Errors.

  18. PVince81 commented on Dec 10, 2015

    @PVince81
    ContributorAuthor

    Ok, so this means we need to not only detect 503, 401 but also detect:

  19. PVince81 commented on Dec 10, 2015

    @PVince81
    ContributorAuthor

    I'm first going to revive #16783.
    But also I'll check whether it is still possible for apps to override this and have their own handlers, just in case.

  20. MorrisJobke commented on Feb 17, 2016

    @MorrisJobke
    Contributor

    Fixed by #16783

  21. lock commented on Aug 6, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  22. locked as resolved and limited conversation to collaborators on Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions