Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Uncaught TypeError: Cannot read property 'upload' of undefined #1372

Closed
bs-thomas opened this issue Feb 22, 2015 · 12 comments
Closed

Uncaught TypeError: Cannot read property 'upload' of undefined #1372

bs-thomas opened this issue Feb 22, 2015 · 12 comments

Comments

@bs-thomas
Copy link

This happens only when chunk is enabled, on S3 mode.

        chunking: {
            enabled: true,
            concurrent: { enabled: true }
        },

Turn on debug mode, then try to upload a big file, then disconnect wifi in the middle. Wait for a bit, until 3 retries are over.

Then, there will be an error:

Uncaught TypeError: Cannot read property 'upload' of undefineds3.jquery.fine-uploader.js:5594 qq.extend._registerProgressHandlers3.jquery.fine-uploader.js:9434 chunked.put.chunked.initHeaders.then.promise.failure.errors3.jquery.fine-uploader.js:1109 (anonymous function)s3.jquery.fine-uploader.js:659 qq.eachs3.jquery.fine-uploader.js:1108 qq.extend.successs3.jquery.fine-uploader.js:9418 (anonymous function)s3.jquery.fine-uploader.js:1109 (anonymous function)s3.jquery.fine-uploader.js:659 qq.eachs3.jquery.fine-uploader.js:1108 qq.extend.successs3.jquery.fine-uploader.js:8494 handleSignatureReceiveds3.jquery.fine-uploader.js:3804 onCompletes3.jquery.fine-uploader.js:3909 (anonymous function)

I've investigated a bit on this...

On line 5560, this gets called: _registerProgressHandler()
On line 5561, it will try to use the handler to get xhr. Unfortunately, it fails to get the xhr.
On line 5594, without checking xhr variable, it tries to assign a new function on top of xhr.upload, and boom, "Cannot read property 'upload'".

I advise to resolve the issue by making a check right before definition of the function.

Something like...

        if( xhr === undefined )
            xhr = {};

        if( xhr.upload === undefined )
            xhr.upload = {};

Btw, I do notice that while most of the time this happens, everyone once a while this does not. I'm not sure about the whole flow of the code, or how the threading works here, but yeah, that's how I see the bug currently.

Last but not least I thought this whole fineuploader thing was really well made. Really love it a lot.

Thanks guys!

Cheers,
Thomas

@rnicholus
Copy link
Member

What version are you using, and what noticeable issue does this error cause (other than the log message)?

On Sun, Feb 22, 2015 at 11:41 AM, thomas83 [email protected]
wrote:

This happens only when chunk is enabled, on S3 mode.
chunking: {
enabled: true,
concurrent: { enabled: true }
},
Turn on debug mode, then try to upload a big file, then disconnect wifi in the middle. Wait for a bit, until 3 retries are over.
Then, there will be an error:
Uncaught TypeError: Cannot read property 'upload' of undefineds3.jquery.fine-uploader.js:5594 qq.extend._registerProgressHandlers3.jquery.fine-uploader.js:9434 chunked.put.chunked.initHeaders.then.promise.failure.errors3.jquery.fine-uploader.js:1109 (anonymous function)s3.jquery.fine-uploader.js:659 qq.eachs3.jquery.fine-uploader.js:1108 qq.extend.successs3.jquery.fine-uploader.js:9418 (anonymous function)s3.jquery.fine-uploader.js:1109 (anonymous function)s3.jquery.fine-uploader.js:659 qq.eachs3.jquery.fine-uploader.js:1108 qq.extend.successs3.jquery.fine-uploader.js:8494 handleSignatureReceiveds3.jquery.fine-uploader.js:3804 onCompletes3.jquery.fine-uploader.js:3909 (anonymous function)
I've investigated a bit on this...
On line 5560, this gets called: _registerProgressHandler()
On line 5561, it will try to use the handler to get xhr. Unfortunately, it fails to get the xhr.
On line 5594, without checking xhr variable, it tries to assign a new function on top of xhr.upload, and boom, "Cannot read property 'upload'".
I advise to resolve the issue by making a check right before definition of the function.

Something like... if( xhr === undefined || xhr.upload === undefined) return;

Btw, I do notice that while most of the time this happens, everyone once a while this does not. I'm not sure about the whole flow of the code, or how the threading works here, but yeah, that's how I see the bug currently.
Last but not least I thought this whole fineuploader thing was really well made. Really love it a lot.
Thanks guys!
Cheers,

Thomas

Reply to this email directly or view it on GitHub:
#1372

@bs-thomas
Copy link
Author

Wow that was some quick response.

There are no noticeable issues. I'm making a wrapper on top of this, so I wanted to make sure every single point goes clear and working the way it's supposed to be. It could be my problem, but I kinda doubt it this time.

I'm using the latest version I downloaded today.

/*!

  • Fine Uploader
    *
  • Copyright 2015, Widen Enterprises, Inc. [email protected]
    *
  • Version: 5.1.3

@rnicholus
Copy link
Member

I believe I have seen this log message in the past.  As you suggested, it is only noticeable when concurrent chunking is enabled.  It can be reproduced when an in progress concurrently chunked upload is canceled.  When an upload of this type fails, fine uploader cancels all chunks (internally), so that is why you are seeing the issue.  I believe the error log message is benign, but I'll look closer before 5.2 is released.

On Sun, Feb 22, 2015 at 11:48 AM, thomas83 [email protected]
wrote:

Wow that was some quick response.
There are no noticeable issues. I'm making a wrapper on top of this, so I wanted to make sure every single point goes clear and working the way it's supposed to be. It could be my problem, but I kinda doubt it this time.
I'm using the latest version I downloaded today.
/*!

* Version: 5.1.3

Reply to this email directly or view it on GitHub:
#1372 (comment)

@bs-thomas
Copy link
Author

Thanks Ray!

@rnicholus
Copy link
Member

I'm not able to reproduce this issue in the develop branch as of 5.2.0-20, so I'm going to assume this has been fixed somehow. If you're able to reproduce in the dev branch w/ 5.2.0. please let me know.

@andreas-venturini
Copy link

I noticed this error today after a user reported that uploads didn't work for them

User agent Mozilla/5.0 (Linux; Android 5.1; LG-H815 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/38.0.2125.102 Mobile Safari/537.36

FineUploader Version 5.5.0

TypeError: Cannot read property 'upload' of undefined
1
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 345 col 4327 in qq.extend._registerProgressHandler
2
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 346 col 27382 in v.initHeaders.then.s.failure.error
3
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12351 in [anonymous]
4
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 8057 in Function.qq.each
5
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12328 in qq.extend.success
6
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 346 col 27172 in [anonymous]
7
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12351 in [anonymous]
8
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 8057 in Function.qq.each
9
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12328 in qq.extend.success
10
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 346 col 14732 in Object.t

@rnicholus
Copy link
Member

Can you elaborate on "didn't work"?
On Wed, Feb 17, 2016 at 8:55 PM Andreas Venturini [email protected]
wrote:

I noticed this error today after a user reported that uploads didn't work
for them

User agent Mozilla/5.0 (Linux; Android 5.1; LG-H815 Build/LMY47D)
AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/38.0.2125.102
Mobile Safari/537.36

FineUploader Version 5.5.0

TypeError: Cannot read property 'upload' of undefined
1
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 345 col 4327 in qq.extend._registerProgressHandler
2
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 346 col 27382 in v.initHeaders.then.s.failure.error
3
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12351 in [anonymous]
4
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 8057 in Function.qq.each
5
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12328 in qq.extend.success
6
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 346 col 27172 in [anonymous]
7
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12351 in [anonymous]
8
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 8057 in Function.qq.each
9
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 343 col 12328 in qq.extend.success
10
File https://XXX.cloudfront.net/assets/application-74cc883326e236859bdeb28fac648581.js line 346 col 14732 in Object.t


Reply to this email directly or view it on GitHub
#1372 (comment)
.

@andreas-venturini
Copy link

I suspect the upload stalled on their mobile device due to mobile network quality issues and was then manually aborted. We didn't receive a final upload failure notice.
Shortly before and after the above error message (all within one minute) we observed XHR returned response code 0 warnings which would indicate network quality issues.

I just wanted to add this here for reference in case someone looks for context of this warning in future.

@rnicholus
Copy link
Member

Can you paste your fine uploader initialization code here?

@andreas-venturini
Copy link

Here is the relevant section that I extracted from the compiled production js

...
  function() {
    this.FileUploader = function() {
      function e(e, t) {
        null == t && (t = {}), this.el = e, this.options = t, this.setupUploader()
      }
      return e.prototype.setupUploader = function() {
        var e, t;
        return t = this, e = null, this.el.fineUploaderS3({
          uploaderType: "basic",
          button: this.el,
          multiple: this.options.multiple,
          maxConnections: this.options.maxConnections || 3,
          validation: {
            acceptFiles: this.options.acceptFiles || null,
            sizeLimit: this.options.sizeLimit || 0,
            minSizeLimit: this.options.minSizeLimit || 0,
            allowedExtensions: this.options.allowedExtensions || []
          },
          request: {
            endpoint: "https://xxx.s3-eu-west-1.amazonaws.com",
            accessKey: "XXX"
          },
          objectProperties: {
            acl: this.options.acl || "public-read",
            key: function(e) {
              var n, i, r;
              return r = "production/" + qq.getUniqueId(), i = this.getName(e), n = t.options.extension || qq.getExtension(i), void 0 !== n && (r += "." + n), r
            }
          },
          signature: {
            endpoint: "/upload_signatures",
            customHeaders: {
              "X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
            }
          },
          uploadSuccess: {
            customHeaders: {
              "X-CSRF-Token": $("meta[name=csrf-token]").attr("content")
            },
            endpoint: this.options.endpoint,
            params: this.options.params || {}
          },
          chunking: {
            enabled: !0,
            concurrent: {
              enabled: !0
            }
          },
          resume: {
            enabled: !0
          },
          iframeSupport: {
            localBlankPagePath: "/upload_success.html"
          },
          retry: {
            autoAttemptsDelay: this.options.autoAttemptsDelay || 5,
            maxAutoAttempts: this.options.maxAutoAttempts || 20,
            enableAuto: !0
          }
        }
....

@rnicholus
Copy link
Member

Seems to be related to #1519. Have a look at that case for a possible solution.

@eyaleee
Copy link

eyaleee commented Jan 1, 2018

hey there @rnicholus - I have this issue you mentioned - I have a multi-chunked upload I'm cancelling and get this error... although it's benign like you said, and it doesn't bother FU to continue to the next file, it's still not a cool thing to have this error thrown. WDYT?

Uncaught TypeError: Cannot read property 'chunking' of undefined
at qq.s3.XhrUploadHandler._getPersistableData (xhr.upload.handler.js:275)
at s3.xhr.upload.handler.js:175
at promise.js:55
at Function.qq.each (util.js:654)
at qq.Promise.success (promise.js:54)
at Object.n [as onComplete] (multipart.initiate.ajax.requester.js:140)
at s (ajax.requester.js:145)
at XMLHttpRequest. (ajax.requester.js:253)

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

No branches or pull requests

4 participants