plupload icon indicating copy to clipboard operation
plupload copied to clipboard

Uncaught TypeError: Cannot read property 'getShim' of null

Open Salasar opened this issue 8 years ago • 15 comments

Plupload version 2.3.3. I use plupload.full.min.js file in the production. After the uploading of a document I got the following error:

Uncaught TypeError: Cannot read property 'getShim' of null
    at n.destroy (plupload.full.min.js?v=dd9e04c:3)
    at plupload.full.min.js?v=dd9e04c:1
    at Object.c [as each] (plupload.full.min.js?v=dd9e04c:1)
    at Object.removeAllInstances (plupload.full.min.js?v=dd9e04c:1)
    at o.destroy (plupload.full.min.js?v=dd9e04c:1)
    at o.e.extend.destroy (plupload.full.min.js?v=dd9e04c:2)
    at c.disconnectRuntime (plupload.full.min.js?v=dd9e04c:1)
    at c.destroy (plupload.full.min.js?v=dd9e04c:1)
    at plupload.full.min.js?v=dd9e04c:4
    at Object.c [as each] (plupload.full.min.js?v=dd9e04c:1)

Rollback to 2.3.2 solves this issue.

Salasar avatar Sep 06 '17 10:09 Salasar

Can you replicate the problem in our playground? Or at least describe your case in more detail.

jayarjo avatar Sep 06 '17 14:09 jayarjo

@jayarjo @Salasar : This error occurs when calling uploader.destroy () after uploading from 4 files or more

Two examples:

One:

In file jquery.plupload.queue.js find

				uploader.bind("PostInit", function(up) {
					// features are populated only after input components are fully instantiated

Add before

                uploader.bind("UploadComplete", function(up, err) {
                    console.log('OK');
                    setTimeout(function() {
                        destroy();
                    }, 1);
                });

An automatic error occurs: error auto

Two:

In file queue_widget.html find

<input type="submit" value="Send" />

Add after

<input onclick="myUpload.destroy();" value="Destroy" type="button"/>

Find

<script type="text/javascript">
$(function() {

Replace with

<script type="text/javascript">
var myUpload;
$(function() {

Find

		silverlight_xap_url : '../../js/Moxie.xap'
	});

Add after:

    myUpload = $("#uploader").pluploadQueue();

After uploading successfully, hit the Destroy button and the error will occur

10-10-2017 2-05-23 ch

hoaquynhtim99 avatar Oct 10 '17 07:10 hoaquynhtim99

The problem seems to be caused by this

Go to File changes tab, line 7907 of bin/js/moxie.dev.js

The XHR destroy is trying to getRuntime. However, the runtime is already cleared earlier during disconnectRuntime

huan086 avatar Oct 16 '17 06:10 huan086

This problem still appears in v2.3.6 :'(

hoaquynhtim99 avatar Nov 07 '17 01:11 hoaquynhtim99

any updates on this?

kimon89 avatar Dec 05 '17 21:12 kimon89

And to add more info, the function getRuntime() will return null, when--according to the code comment--"client is not connected".

The getRuntime() function is called in 111 places in the repository and the possibility of being null is never tested. It seems like the most robust fix would be to update all those places to intelligently handle the case when null is returned.

A nuclear option would be to have getRuntime() return a stub object that behaves like a Runtime but does nothing. For example:

image

kensnyder avatar Dec 21 '17 18:12 kensnyder

This problem still appears in plupload v3.1.2 moxie v1.5.8 :'(

hoaquynhtim99 avatar Apr 26 '18 08:04 hoaquynhtim99

hey is there any update on that case or a workaround? appreciate any suggestings :)

I'm using v3.1.2 moxie v1.5.8

paul-pfeiffer avatar Sep 08 '18 11:09 paul-pfeiffer

I solved it by removing the focusout event. Just add

$('form#addNote.form-validate-jquery').off("focusout");

in document.ready.

paul-pfeiffer avatar Sep 08 '18 15:09 paul-pfeiffer

This did not help me. Still experiencing this error. This error occurs only if I have uploaded a file and then I try to destroy the instance of plupload. For test I am using wrong url, which returns status code 200, but does not upload image. Then when I destroy the instance I get the error.

neverlose-lv avatar Jan 04 '19 14:01 neverlose-lv

I found that uploader.removeAllEventListeners() seems to do the job of at least disabling the uploader.

richorama avatar Feb 07 '19 03:02 richorama

I have the exact same issue as @neverlose-lv described it. Error appeared after updating from 2.3.2 to 2.3.6. Maybe it has something to do with the 2.3.4 release?

Expose whole moxie namespace under plupload.moxie (mostly for smooth integration into environments like Webpack).

or with this change

Update mOxie to: v1.5.6.

Baedda avatar Jul 02 '19 13:07 Baedda

I actually have a similar problem. I added:


        FileUploaded: function(up, file, info) {

            console.log(info);
            // Called when file has finished uploading
            //log('[FileUploaded] File:', file, "\nInfo:", info);
            if (response.error) alert(response.error);
            handle.destroy();
        },

where 'handle' is actually 'this' , set in PostInit.


			PostInit: function() {
				// Called after initialization is finished and internal event handlers bound
				handle = this;
			},

sscotti avatar Nov 20 '20 18:11 sscotti

My bugfix.

Change: https://github.com/moxiecode/plupload/blob/6d2af806ff03fb52ff4db3b391738b706ce65084/js/moxie.js#L4683-L4686

To:

this.destroy = function() {
    // Bugfix begin.
    this.getRuntime().getShim().removeInstance(this.uid);
    // Bugfix end.
    this.disconnectRuntime();
    this.unbindAll();
};

michalzielanski avatar May 06 '21 13:05 michalzielanski

find all this.getRuntime().getShim() in the source file and replace them with null check: this.getRuntime()?.getShim()

this does not solve empty object problem. it is a structural issue but at least removes the error and main functionality in intact.

KeremArdicli avatar Oct 19 '23 14:10 KeremArdicli