laravel-debugbar icon indicating copy to clipboard operation
laravel-debugbar copied to clipboard

Uncaught (in promise) DOMException: The user aborted a request.

Open tworonin opened this issue 3 years ago • 4 comments

First let me say thank you for this package and that I find it immensely helpful.

I just wanted to report this behavior for anyone who finds themselves distracted by it for two hours like myself.

When using AbortController() to cancel fetch requests, I kept seeing Uncaught (in promise) DOMException: The user aborted a request. in the console despite the fact that I was explicitly catching the error in my function. It was driving me crazy. I finally traced back through the log and found that the unhandled exception originates in debugbar in this code:

bindToFetch: function() {
    var self = this;
    var proxied = window.fetch;

    if (proxied !== undefined && proxied.polyfill !== undefined) {
        return;
    }

    window.fetch = function () {
        var promise = proxied.apply(this, arguments);

        promise.then(function (response) {
            self.handle(response);
        });

        return promise;
    };
},

Specifically here:

promise.then(function (response) {
    self.handle(response);
});

This isn't really a big deal since it doesn't inhibit debugbar from doing its job when tracking AJAX requests. Again, just wanted to report this in case some future frustrated person is trying to figure out why they're seeing the console error.

Thanks for the excellent package!

tworonin avatar Oct 05 '22 15:10 tworonin

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jun 18 '23 15:06 stale[bot]

This problem is still there. When paired with React - it becomes a real problem. AbortController for fetch() is a common use case and it should be handled correctly.

swayok avatar Dec 14 '23 14:12 swayok

@swayok hi, feel free to make a PR fixing that

parallels999 avatar Dec 14 '23 14:12 parallels999

@parallels999 Done: https://github.com/maximebf/php-debugbar/pull/585

swayok avatar Dec 14 '23 14:12 swayok