web-maker icon indicating copy to clipboard operation
web-maker copied to clipboard

Bug: DataCloneError: The object could not be cloned.

Open X-Raym opened this issue 6 years ago • 4 comments

Meta info

  • Is this a bug or suggestion?: Bug
  • Version (click on help icon in footer): 4.0.3
  • Context - Web app, Chrome extension or both?: Firefox 70.0.0.1

Hi,

I have problem with promises not being able to access variable declared outisde.

I always have this warning :

DataCloneError: The object could not be cloned.

I can tweak my code form place to place but on some case it is really problematic, especially cause it beaks the script (the variables values are not pass where the error occurs). Also, the bug doesn't occur when the web page is exported and loaded in any browser, so it is just a bug in this editor.

Can you please help ?

Here is a code snippet for Firefox DOC for promises ( https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise ):

var promise1 = new Promise(function(resolve, reject) {
  setTimeout(function() {
    resolve('foo');
  }, 300);
});

promise1.then(function(value) {
  console.log(value);
  // expected output: "foo"
});

console.log(promise1);

This code snippet trigger the error I mentionned.

X-Raym avatar Nov 08 '19 22:11 X-Raym

Hi! Just to confirm, it is this line that causes the error: console.log(promise1);. Correct? When you say "promises not being able to access variable declared outside", do you mean something else?

chinchang avatar Nov 09 '19 11:11 chinchang

@chinchang

Yess, pretty sure it is console.log(promise1);. I had issue with other scripts and the console.log breaks the things.

promises not being able to access variable declared outside

This is my attempt to formulate what I think the bug is related too. It may not be that exactly. But I had the same error message with various other code snippets, and it always invoked some kind of asynchronous functions (fetch, promise, callback etc...). I guess fixing for one will fix the other.

Meanwhile I unfortunately had to change editor cause it really breaks often for me as I'm working with code which involves such things.

Good luck for fixing ! Hope it could be soon hehe :)

Thx the quick answer !

X-Raym avatar Nov 09 '19 15:11 X-Raym

Sure. Actually the issue is that anything you pass to console.log gets cloned/serialized to be transmitted from iframe to top window. And Promise (and other things) can't be serialized, so it errors out. This is a serious issue. I'll fix it asap. Thanks for reporting.

chinchang avatar Nov 10 '19 15:11 chinchang

Yeah I suspect this serialization needs can be the source of various issue. The first time I had errors it was with passing HTML elements in callbacks. These cant be serialized either and it didnt work.

Thx for your support !

X-Raym avatar Nov 10 '19 17:11 X-Raym