Issue with Storing Functions in JavaScript Query

We were previously using a JavaScript query to store functions. However, it stopped working on its own and started throwing the following error:

jsLib: Failed to execute 'postMessage' on 'Window': function getAttribute() { return "attribute"; } could not be cloned.

With this being the function function getAttribute() { return "attribute"; }. This functionality was working as expected as at 29th of February, but started throwing the above error on the 4th of March.

How can we restore the previous functionality.

1 Like

Thanks for the report @Abdul_Mumin, taking a look.

@Abdul_Mumin Can you share how / where you are calling the function for it to throw the error?

The functions were invoked from various sections of the application, such as when displaying a label or when passing a payload to a resource query. It's important to note that the JavaScript query needs to be triggered before its functions are accessible. In this particular scenario, the JavaScript query is triggered on load, and that's when the error occurs.

@joeBumbaca

@Abdul_Mumin I'm unable to reproduce the issue, can you share either screenshots of how this was set up, or an export of an app where you are seeing the error. Thanks!

@joeBumbaca Here are the steps to reproduce it

  1. Add a JavaScript query
  2. Write a function in the JavaScript query code and return the function within an object.
  3. Run the function, then you get the error
1 Like

Thanks @Abdul_Mumin, got a good reproduction going and submitted a bug report. I will keep you updated here as I have any new information to share.

Hey @Abdul_Mumin, heard back from the team that this functionality will not be added back into the product. Ultimately, allowing this was unintentional and can let our users do some dangerous things. We are working on some other ways of adding functions into Retool and I'll update you here as those get released.

Hi @Abdul_Mumin,

Thanks again for reaching out about this -- I'm an engineer at Retool working on logic + code reusability, and I would love to learn more about your use cases. I also wanted to point you to a closed alpha we just launched for Sync Functions, which may be of interest to you. Please me know if you are open to chatting!

Best,
Erin

1 Like

Hi @Erin_Masatsugu ,

Thanks for getting back. I believe the Sync Functions could offer a solution to the challenges we're facing. I'm definitely interested in giving it a try. I appreciate you pointing me in that direction.

Yes, I'm open to chatting further about our use cases and how Sync Functions 3 might fit into our workflow.

2 Likes