[File Transfer Plugin] Error log filling up with 'Invalid call of the 'UploadProgress' client action..'

Forge Component
(8)
Published on 2019-12-18 by Experts
8 votes
Published on 2019-12-18 by Experts

Hi,

We use this plugin and the infamous Invalid call error is clogging our logs.

Invalid call of the 'UploadProgress' client action of the '[..]' since the latter is not currently active. This is likely due to a platform's client action being used as an event handler or in a setTimeout function. Consider removing this call by using the 'On Destroy' event of the screen/block or moving your logic to a global client action.

Since the callbacks are already attached to the scope of the screen and thus should be destroyed on navigate, we were wondering how these still can occur and how we can prevent them.

Kind regards,
Rob

Hi,


Somehow the onDestroy event isn't stopping the upload events from being triggered.

A possible fix can be done by replacing the JS code in the OnReady - RegisterCallbacks by:


require(["PluginManager"], function(module) {  var isActive = true;  var onReady = function(scope) {    scope.uploadCallback = {};    scope.uploadCallback.hasPermission = false;        scope.uploadCallback.uploadComplete = scope.newCallback(function(entry) {      if (isActive) {        $actions.UploadComplete(JSON.stringify(entry));      }    });    scope.uploadCallback.uploadError = scope.newCallback(function(error) {      if (isActive) {        $actions.UploadError(JSON.stringify(error));      }    });    scope.uploadCallback.uploadProgress = scope.newCallback(function(progress) {      if (isActive) {        $actions.UploadProgress(JSON.stringify(progress));      }    });  }
  var onDestroy = function(scope) {    isActive = false;  }
  module.createScope("FileTransfer_upload", onReady, onDestroy);  $resolve();});


Cheers!

David