Closed rakeshar3796 closed 2 months ago
You cannot clone a function. Think of copy:true
as JSON.stringify
with additional handling for Map
, Set
, bigint, etc. It is the structured clone algorithm. What would it even mean to clone a function which is a closure that references the entire nodejs heap?
Understood @laverdet but for this scenario i'll handle this with some workaround because it's in my control but this same happens in the user script there i won't have control like
let abc = {
arrayBuffer: function () {
return "arraybuffer"
}
};
log("LOGGER", abc);
if they try to log i'll face the same problem, is this actually a problem or am missing anything?
Is Your Question Already Answered?
Personal Diagnostics
Please answer the following questions:
JavaScript includes a
setTimeout
function:Functions are a type of primitive value in JavaScript:
Objects can be shared between isolates:
The Code
main.mjs
and then runnode main.mjs
.My intention here is to pass an function as an argument from the isolate to the host and when i'm doing this i've faced an error "could not be cloned" when the arguments options is set to
copy:true
for__host_fn_call
but when i change it to reference am still getting the error. Is this the right approach or am i missing anything here?