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

DOMException: The user aborted a request with onDownloadProgress and request cancelation #132

Open
AlissonRA opened this issue Oct 2, 2020 · 5 comments

Comments

@AlissonRA
Copy link

AlissonRA commented Oct 2, 2020

good afternoon

I am having a problem when trying to cancel a request for aws with the onDownloadProgress () event instantiated!

    const controller = new AbortController ()

    setTimeout (() => {
      console.log ('abort', Date.now ())
      controller.abort ()
    }, 2500)

    try {
      console.log ('request', Date.now ())
      await this. $ http.get ('https://storage-dev-test.s3.us-east-2.amazonaws.com/navicat121_premium_en_x64.exe', {
        signal: controller.signal,
        hooks: {
          beforeRequest: [
            (request) => {
              request.headers.delete ('Authorization')
            }
          ]
        },
        onDownloadProgress: (progress) => {
          console.log (progress)
        }
      }). then (async (responseAWS) => {
        await responseAWS.arrayBuffer (). then ((responseEnd) => {
          console.log (responseEnd)
        })
      })
    } catch (error) {
      console.log ('exception', Date.now ())
      if (error.name === 'AbortError') {
        console.log ('Fetch aborted')
      } else {
        console.error ('Fetch error:', error)
      }
    }

the error returned in the console is as follows:

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

Now if I remove the code part:

onDownloadProgress: (progress) => {
  console.log (progress)
}

No error is returned on the console. can anybody help me? because I need onDownloadProgress but with the error breaking the code I can't make the necessary finalizations.

@Geminii
Copy link
Contributor

Geminii commented Nov 22, 2020

Hi @AlissonRA 👋
I don't understand the options that you passed in your call : await this.$http.get('URL', { OPTIONS })
Relative to the options documentation, there is no configuration for onDownloadProgress.

Maybe you want to add a hook on it ? Currently, there are only 3 hooks supported by http module : onRequest, onResponse & onError.

@AlissonRA
Copy link
Author

Hello @Geminii

OnDownloadProgress is not an option for nuxt/http but for Ky.
Since that is what nuxt/http uses behind the scenes.

Copy link
Member

atinux commented Dec 9, 2020

The options are forwarded directly to key, see here.

This error is weird, could you try directly by using ky and confirm there is no error with it?

@pi0 pi0 changed the title Uncaught (in promise) DOMException: The user aborted a request. DOMException: The user aborted a request with onDownloadProgress and request cancelation Dec 9, 2020
@AlissonRA
Copy link
Author

Hello @atinux

I tested with the native ky library and got the same error! Now what can I do? Do I have to open an issue there and ask for correction of this error and as soon as it is corrected return here and ask for the package update or wait for your update to resolve the problem?

Copy link
Member

atinux commented Dec 11, 2020

Exactly @AlissonRA

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

No branches or pull requests

3 participants