Using the await in the non-async callback function causes the below error on the server log.
SyntaxError: Unexpected reserved word
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)
[05:51:47][Error] Failed to load resource bennys
2. Run the server.
3. Error log appeared in the console.
SyntaxError: Unexpected reserved word
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)
[05:51:47][Error] Failed to load resource bennys
### Expected behaviour
alt:V's `js-module` should generate logs like Node.js official error.
This is the normal error on Node.js console.
await new Promise((res) => {
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
### Additional context
_No response_
### Operating system
Windows 10
### Version
dev/15.0-dev15
### Scope
server
### Reproduction tested
- [X] I confirm that I have made sure that this issue is also present on the newest dev version
Description of the problem
Using the
await
in thenon-async
callback function causes the below error on the server log.Reproduction steps
setTimeout(() => { await new Promise((res) => { setTimeout(() => { console.log('Hello!!!'); res(); }, 1000); }); }, 0);
SyntaxError: Unexpected reserved word at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14) [05:51:47][Error] Failed to load resource bennys
await new Promise((res) => { ^^^^^ SyntaxError: await is only valid in async functions and the top level bodies of modules