# top_level_await

> A module uses await or for await outside any function.

A module uses await or for await outside any function.

| | |
| --- | --- |
| Kind | Build or validation problem |
| Reported by | Archive and source validation |
| `disko` exit code | 1 (problems) |

A module uses `await` or `for await` outside any function. Top-level code must
run synchronously, because it has to declare the game and its initial menu
within the startup deadline.

## Wrong

```js title="src/main.js"
const config = await loadConfig();
```

## Right

```js title="src/main.js"
async function start() {
  const config = await loadConfig();
  // use config here
}

start();
```

Move the waiting into an `async` function, or replace the value with a
constant.

## See also

- [Project structure & imports](/games/project-structure)
- [`import_dynamic`](/errors/import_dynamic)
