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

IE9: Success callback prematurely called on FileAPI.upload.progress #528

Closed
Oceanswave opened this issue Jan 29, 2015 · 9 comments
Closed

Comments

@Oceanswave
Copy link

On browsers that use the FileAPI as a fallback, it appears that if the POST exceeds 10 seconds the .success callback is raised, but the data returned is null

If I use fiddler to look at client/server traffic, I don't see a 204, just my file upload, which completes successfully AFTER the .success() method is called in my controller.

FileAPI Debug:

FileAPI.debug = true
true
FlashAPI.event.mouseenter: [object Object](js -> flash).multiple: false
(js -> flash).accept: *
FlashAPI.event.select: [object Object]
FlashAPI.Form.toData
FlashAPI.XHR._send: fileapi14225600781572 -> 1422560097419812
(js -> flash).upload: [object Object]
FlashAPI.upload.progress
$upload.upload success callback. Status: {"status":204,"config":{"method":"POST","transformResponse":[null],"url":"myService.aspx","file":{"flashId":"fileapi14225600781572","id":"1422560097419812","size":164382,"type":"xlsx","name":"data.xlsx"},"timeout":100000000,"headers":{"Accept":"application/json, text/plain, /"},"data":{"data":[{"key":"file","val":{"flashId":"fileapi14225600781572","id":"1422560097419812","size":164382,"type":"xlsx","name":"data.xlsx"},"name":"data.xlsx"}],"__isFileAPIShim":true},"start":"2015-01-29T19:34:57.429Z","end":"2015-01-29T19:35:07.442Z"},"statusText":"No Content"}
FlashAPI.upload.complete
xhr.end: 200
SCRIPT5007: Unable to get property 'statusText' of undefined or null reference

@Oceanswave Oceanswave changed the title IE9: Premature success 204 returned by FileAPI on long POSTs IE9: Success callback prematurely called on FileAPI.upload.progress Jan 29, 2015
@Oceanswave
Copy link
Author

Looking at the shim -- it appears that there's a timeout after 10 seconds at line 126.

if I remove this, or change the delay to something larger, things work as expected.
if (e.total === e.loaded) {
// fix flash issue that doesn't call complete if there is no response text from the server
var _this = this
setTimeout(function() {
if (!xhr.__completed) {
xhr.getAllResponseHeaders = function(){};
_this.complete(null, {status: 204, statusText: 'No Content'});
}
}, 10000);
}

Can the 10 second delay be surfaced as a configuration setting? There would also seem to be side effects if FileAPI calls the progress callback multiple times.

Thanks,

@danialfarid
Copy link
Owner

There is a check before that timeout if (e.total === e.loaded) { so it should be only set if the upload is completed and progress is 100%.
So it should only happen if your server doesn't send any response back after 10 seconds of successfully sending all the file content, which since the file is send completely so most probably your response will be success.
I can add that to the FileAPI configuration in case server takes way longer to process the successfully uploaded file and send a response back, but it should be very rare

@Oceanswave
Copy link
Author

The service takes some time to process the file, which is why I ran up against this. A configuration setting would be great -- thanks!

@danialfarid
Copy link
Owner

added the option to FileAPI:
FileAPI.noContentTimeout: 10000

since version 3.0.0

@Oceanswave
Copy link
Author

Thank you!

@matgardon
Copy link

Sorry to ask, but this doesn't seem to work for me (following the readme : FileAPI = { ... }), and looking at the offending code in the shim, the 10000 value in setTimeout is still hard coded in the 3.0.0 version of your package.

Did I miss something ?

@Oceanswave
Copy link
Author

Yeah, I don't think the angular-file-upload release package got properly updated for 3.0.0 -- none of the version numbers have been updated in the files... The demos folder does contain a newer version but outside of that I'm not sure where the 3.0.0 code went.

Some checkin bombed or some grunt task failed methinks.

See #536

@matgardon
Copy link

Yup, thanks for the update ! Well for now I hard coded another value and it works.

@danialfarid
Copy link
Owner

It was a grunt issue, the name in package.json is now ng-file-upload since angular-file-upload name was already taken in both npm and bower registry so the module is registered there with that name.
In the angular dependencies you can use both names.

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