Bring async/await support to FDK

I tried to use an async function in my current project, but it seems FDK doesn’t support async/await - “fdk pack” returns an “Unexpected token function” error. I have no problem running the app locally. Using async function helps greatly with throttling requests and performing sequential operations, so can we expect support for this in the later versions of FDK?

Hi Vlad,
Thanks for bringing it up! Currently, FDK validates the frontend code against ECMA2015. However, async, await functionality was introduced as a part of ECMA2017. This results in an unfortunate Unexpected token function error during fdk pack or fdk validate. At the moment, Babel can be used to convert the code to a compatible version. In the meantime, while we come up with a solution, I am moving this to our Feedback category.

1 Like

Hey @Hem Thanks for your helpful reply. I’m also currently facing the same problem with the async/await functionality in my app and fdk pack isn’t working. It gives the same error as “Unexpected token function”. I thought ES5 or ES6 would support async/await functionality however I didn’t knew it’s from ECMA2017. Hope, To have a better solution for this problem since callback() method is a bit difficult and weird for me however, async/await is more easier and convenient for me. BTW, is there anyway, that I can change the ES version for my FDK pack? Because my app is working in my developer environment with fdk run, but it doesn’t works with the fdk pack. So maybe if I can change the ESLint or at least can make somehow my app published to my custom app it will be usable at least for my company. Thanks again.

Hello @Shamsuzzaman_Sadi,

Thanks for the feedback. We will consider bringing this support natively to the FDK since clearly async/await makes app code more readable and maintainable.

We don’t however currently have a way of modifying the ES version used by the FDK.

Still can’t use async/await? Disappointing :frowning:

Jay,

We can use async await now in FDK. Please verify your recommended node version and also update your fdk to the latest version and check. If this is still happening, please let us know here. :slight_smile:

image

my node is old…v11.15.0. But node 7.6 started supporting async/await.

Oh. My node version is v12.13.1 and I am able to use it.

I know it should not make a difference, but upgrade your node maybe? Also what’s the error you are getting? Can you please quote that here.

1 Like

Adding on to @yusrakhatri’s helpful comments, can you shed some light on the errors that you are getting? Is this observed in frontend code or backend?

2 Likes

It was when I ran fdk validate on the command line. It was like a ‘parsing error: unexpected token’ at the async function line.

Next time I get to that point, I’ll loop back with the exact error but it was something along those lines.

@jbwieg09 - You are right Jay.

When you build the app, there are two parts to it.

  1. app/app.js and related js will run in browser.
  2. server/ and related js will run in node environment.

We took steps to allow async await in the server/ files and folders, but fdk will still throw an error if javascript that runs in browser uses async await. Long ago, browsers didn’t have proper support. But we have reconsidered this decision to allow ES6 features very soon.

cc: @vivek.kannan @harish.janjam

2 Likes

@Saif, @Hem

We’ve built our app with all of the latest JS features, but due to limitations in FDK. We are unable to proceed further, will you please let us know the expected timeline to include the latest features in FDK so that we’ll be able to proceed further.

Many Thanks :slightly_smiling_face:

1 Like

+1 on this.

If async/await is not supported - this should also be checked on fdk run. I’ve just spent a good amount of time writing and testing an app, and now that I’m trying to build it, it’s finally told me I can’t use this.

4 Likes

@participators @harish.janjam @Ganesh_Balaji

With FDK v7.0.0 || ES6+ features are supported.

3 Likes