-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Labels
ECWoC26IMPORTANTbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededlevel 1wocs
Description
While running the frontend development server using Vite, the application crashes with an internal server error related to incorrect usage of await.
The error indicates that await is being used outside of an async function, which is not allowed in regular function scopes in TypeScript/JavaScript.
β Error Message
[vite] Internal server error: `await` is only allowed within async functions and at the top levels of modules
Plugin: vite:oxc
File: src/shared/component/v1/LoginPage.tsx:80:23const response = await apiService.login(email, password)π Affected File
src/shared/component/v1/LoginPage.tsx
Line: ~80
π Root Cause (Expected)
The await keyword is used inside a function that is not marked as async, or it is placed directly inside a React component body instead of an event handler or effect.
Common causes:
awaitused directly inside a React component bodyawaitused inside a normal function instead of anasyncfunction- Missing
asynckeyword on a handler likehandleLogin
β Expected Behavior
- The login API call should execute inside an
asyncfunction - The Vite dev server should start without crashing
- Login flow should work correctly
π οΈ Suggested Fix
Wrap the await call inside an async function, for example:
const handleLogin = async () => {
try {
const response = await apiService.login(email, password)
if (!response.success) {
// handle error
}
} catch (error) {
console.error(error)
}
}And call it from an event handler:
<button onClick={handleLogin}>Login</button>π Steps to Reproduce
-
Clone the repository
git clone <repo-url>
-
Install dependencies
pnpm install
-
Start the dev server
pnpm dev
-
Observe the Vite internal server error
π§© Environment
- Framework: React + TypeScript
- Bundler: Vite
- Package Manager: pnpm
- OS: Linux

Metadata
Metadata
Assignees
Labels
ECWoC26IMPORTANTbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededlevel 1wocs