Await is only valid in async functions and the top level bodies of modules

Hi there! I'm facing this issue while running a js query in our self-hosted retool.

currently, we have 2 retools, 1 is self-hosted and the 2nd one, we use retool's hosting. we created the same tools on both retools but on the self-hosted retool we are getting this error:

> await is only valid in async functions and the top-level bodies of modules

but on retool's hosted retool it's working fine.

we created a js query and put await while triggering some queries. for example:

await queryGetUser.trigger()
await queryUpdateUser.trigger()

can anyone tell me what's the issue in it?

Hi @samad324! Top-level await has been feature flagged for self-hosted instances up until 2.87, there are three options here

  1. Upgrading!
  2. I can set the feature flag for your instance that enables top-level await
  3. Using an async wrapper for your JS query:
return (async () => {
  /* some of your script here! */
  await queryGetUser.trigger();
  await queryUpdateUser.trigger();
  /* the rest of your script here! */