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

Add timeout to xhr request #657

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FelipeBarrosCruz
Copy link

Set timeout into XMLHttpRequest Object

@nervgh
Copy link
Owner

nervgh commented Jul 28, 2016

What about of the iframeTransport?

@nikryden
Copy link

What is happening to this request?

@nervgh
Copy link
Owner

nervgh commented Mar 22, 2017

@nikryden it is frozen. We should handle this option for non XHR requests somehow.

@DanRamGim
Copy link

I have just found my solution, you can add this lines on angular-file-upload.min.js

After this lines:

o = e._xhr = new XMLHttpRequest; if (e.disableMultipart ? t = e._file : (t = new F, f(e.formData, function (e) { f(e, function (e, n) { t.append(n, e) }) }), t.append(e.alias, e._file, e.file.name)), "number" != typeof e._file.size) throw new TypeError("The file specified is no longer valid");

And before this lines:
o.upload.onprogress = function (t) { var o = Math.round(t.lengthComputable ? 100 * t.loaded / t.total : 0);

You can add your code, this is mine: e._xhr.timeout = 3600000; e._xhr.ontimeout= function(){e.isError = true; e.progress = 0; alert('El servidor no ha respondido, favor de intentarlo nuevamente')};

This makes the timeout of an hour long and it deletes the progress and show that you had an error, after that I send an alert.

@ygj6 ygj6 mentioned this pull request Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants