plupload
plupload copied to clipboard
Uncaught TypeError: Cannot read property 'getShim' of null
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.
Can you replicate the problem in our playground? Or at least describe your case in more detail.
@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:

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

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
This problem still appears in v2.3.6 :'(
any updates on this?
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:

This problem still appears in plupload v3.1.2 moxie v1.5.8 :'(
hey is there any update on that case or a workaround? appreciate any suggestings :)
I'm using v3.1.2 moxie v1.5.8
I solved it by removing the focusout event. Just add
$('form#addNote.form-validate-jquery').off("focusout");
in document.ready.
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.
I found that uploader.removeAllEventListeners() seems to do the job of at least disabling the uploader.
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.
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;
},
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();
};
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.