What happens if you omit await
If you omit await, you get the Promise itself instead of the result: a promise that will settle some day but has not settled yet. Without await you do not wait for the result, you simply create a promise and move on.
Theory
TL;DR
- Calling an
asyncfunction withoutawaitreturns aPromise, not a value. - Execution is not suspended: the code moves on at once and the function runs in the background.
- Reading a field of the result (
user.name) givesundefined; that is a logic bug, not a syntax error. try...catchwill not catch arejectif you did notawaitit.- Sometimes omitting
awaitis correct: tasks start in parallel and are awaited withPromise.all. return await promisein a plainreturnis redundant,asyncwraps the result anyway.
Quick example
async function getData() {
return 'Data';
}
async function main() {
const withoutAwait = getData(); // Promise { 'Data' }
const withAwait = await getData(); // 'Data'
console.log(withoutAwait, withAwait);
}
main();Without await the variable holds a promise
Example 1, without await a promise is returned
async function getData() {
return 'Data';
}
async function main() {
const result = getData(); // no await
console.log(result);
}
main();Output:
Promise { 'Data' }Why:
getData()is anasyncfunction, so it always returns a promise;- without
awaityou get a Promise object, not'Data'.
Example 2, with await
async function main() {
const result = await getData(); // waited for it
console.log(result);
}
main();Output:
Dataawait "unwraps" the promise and returns its value.
The code moves on without waiting
Example 3, no await, so the code ran ahead
async function delay() {
await new Promise(res => setTimeout(res, 2000));
console.log('Finished after 2 seconds');
}
async function run() {
delay(); // we do not wait!
console.log('Moving on');
}
run();Output:
Moving on
Finished after 2 secondsWithout await execution is not suspended: delay() is started in the background while the program moves on.
Example 4, a missing await gives the wrong result
async function fetchUser() {
return { name: 'Alex' };
}
async function showUser() {
const user = fetchUser(); // forgot await
console.log('User name:', user.name);
}
showUser();Output:
User name: undefinedBecause user is not an object but a Promise, which has no name field. So it is a logic bug, not a syntax error.
When await is left out on purpose
Example 5, parallel tasks. Sometimes omitting await is the right thing, when you want to start operations in parallel:
async function load() {
const userPromise = fetch('/api/user');
const postsPromise = fetch('/api/posts');
// wait for both in parallel
const [user, posts] = await Promise.all([userPromise, postsPromise]);
console.log('Both responses received');
}Had you put await right after each fetch, they would run one after another instead of at the same time.
Example 6, no await when returning
async function foo() {
return await Promise.resolve('OK');
}Here await is redundant, you can simply write:
async function foo() {
return Promise.resolve('OK');
}because an async function wraps the result in a promise anyway.
Under the hood: what really happens
When you call an async function:
const p = myAsyncFunction();JavaScript immediately returns a Promise object, while the code inside starts running asynchronously. If you do not put await, that promise simply hangs "in the air", and you never use the result of its work.
Common problems without await
| Mistake | What happens |
|---|---|
Forgot await when calling an async function | The variable holds a Promise, not the result |
Returning without await inside another async | May return an "unfinished" promise |
| Inconsistent data | The code moves on while the promise has not settled |
| Errors are not caught | try...catch misses the reject because you never awaited it |
Think of
awaitas "waiting for your order":
- with
await: you stand at the counter, wait for the coffee and get your cup;- without
await: you just placed the order and walked away, the coffee gets made but you never picked it up.
| Scenario | What happens |
|---|---|
await omitted | The function returns a Promise and execution continues at once |
await used | Execution is suspended until the promise settles |
An error without await | try...catch misses it, the promise was never awaited |
When not to use await | When starting parallel tasks (Promise.all) |
Common mistakes
- Reading fields of the result without
await.user.nameon a promise is alwaysundefined, and you get no error at all. - Relying on
try...catchwithoutawait. The block finishes before the promise rejects, and you end up with an unhandled rejection. - Forgetting
awaitin areturninsidetry. The error is caught by the caller, not by the localcatch. - Putting
awaitin front of every independent request. Parallel operations should start withoutawaitand be collected withPromise.all. - Assuming that without
awaitthe function does not run. It starts immediately, nobody is just waiting for its result.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.