sending code to puck.js causes reset() error

Posted on
  • Hi all,

    been working with the puck.js for a while now and every now and then I get an error upon loading code (via WebBT/Chrome) to my puck.

    It seems to trigger a reset which seems to fail:

    Uncaught Error: Expecting a function to call, got Number
    at line 1 col 1
    reset();
    ^

    See also attached screenshot - this happens even when just loading one line of code to the puck...

    (hard-)resetting the puck fixes that for a while, but the issue eventually comes back.

    Any ideas?


    1 Attachment

    • Screenshot 2019-12-19 at 10.15.50.png
  • ...since the console.log() uses the same and only available 'communication channel' it interferes with the upload... therefore, put your code into a setTimeout() function, or - even better - into 'the' onInit(){ ... } function and add the timeout to the code like this:

    function onInit() {
      // your code
    }
    
    setTimeout(onInit,999); // while dev, remove before upload for save()
    
  • Thanks for explaining the background on the communication channel - seeing this I now understand the reason for the error.

    Using your code snippet fixed the error, thanks for that, also!

  • I'm not sure if this helps, but:

    Expecting a function to call, got Number
    at line 1 col 1
    reset();
    

    would happen if you did something like global.reset=1 which set reset to a number. It seems unlikely that you would have done that however

  • Thanks for your idea & feedback, Gordon!

    This error occurs prior to loading code to the puck, seems to be during the (standard) reset during the upload procedure - AFAIK there was some switch to "disable reset upon code upload" in the Web IDE...

  • The standard reset procedure involves just calling reset() - so if you had set global.reset=a_number for some reason this is exactly the error you'd get. For example:

    >global.reset=1;
    =1
    >reset()
    Uncaught Error: Expecting a function to call, got Number
     at line 1 col 1
    reset()
    ^
    
  • Thanks Gordon - that's it! That was the issue - I did have a variable called "reset" which caused this behaviour... Sorry, my bad...
    Renaming fixed it - the error is gone - thanks again!

    Will now close this thread

About

sending code to puck.js causes reset() error

Posted by Avatar for dysc @dysc

Actions