Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async\Await usage in pre\post requests leads to SyntaxError 'await is only valid in async functions and the top level bodies of modules' #3288

Open
TimmiTester opened this issue Oct 2, 2024 · 1 comment

Comments

@TimmiTester
Copy link

TimmiTester commented Oct 2, 2024

Hello, I've tried to search everywhere, but can't find any proof for this issue or is it the issue at all. Please confrim whether it's the issue or not.

  1. Newman Version: 6.2.1
  2. OS details: WIn11 x64, node 20.10.0
  3. Are you using Newman as a library, or via the CLI?: library
  4. Did you encounter this recently, or has this bug always been there: i think it's always been there
  5. Expected behaviour: like desktop Postman to be able to use top level async\await
  6. Command / script used to run Newman: -
  7. Sample collection, and auxiliary files (minus the sensitive details): -
  8. Screenshots (if applicable):
    general line, no async\await
    image

line with async\await
image

Steps to reproduce the problem:

  1. Generate collection
  2. Add any pre-request containing await Promise.resolve()
  3. Run the collection
  4. Check that async\await usage leads to pre-request error
@appurva21
Copy link
Member

Hey @TimmiTester!

Based on the error, I assume you are trying to use await outside of an async function. Support for top-level await is not yet available on Newman. We are planning on releasing a major version with multiple improvements in the coming weeks, and this will be part of that. I'll update this thread once it is available.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants