Back to Blog
Developer guide
JAVASCRIPTJune 17, 2026

Common JavaScript Async Await Errors Explained

Async/await is a powerful feature in JavaScript that allows developers to write asynchronous code that's easier to read and maintain. However, like any other feature, it's not immune to errors. In this article, we'll explore some common JavaScript async await errors, their causes, and step-by-step solutions to help you fix them and improve your application's performance and reliability.

1. Uncaught (in promise) SyntaxError: await is only valid in async functions

This error occurs when you try to use the await keyword outside of an async function. The await keyword can only be used within an async function to pause the execution of the surrounding code until a promise is resolved or rejected.

Why It Happens

You're trying to use await in a non-async function or outside of a function altogether.

How to Fix It

Wrap the code that uses await in an async function. For example, if you have a non-async function that uses await, change it to an async function like this: async function myFunction() { await ... }.


2. UnhandledPromiseRejection: Unhandled promise rejection. This error originated either by throwing inside an async function without a catch block, or by rejecting a promise that was not handled with .catch().

This error occurs when a promise is rejected and there's no catch block to handle it. When a promise is rejected, it's essential to catch and handle the error to prevent the application from crashing.

Why It Happens

You're not catching and handling promise rejections in your async code.

How to Fix It

Add a catch block to your async function to handle promise rejections. For example, if you have an async function that returns a promise, wrap it in a try-catch block like this: async function myFunction() { try { await ... } catch (error) { console.error(error) } }.


3. TypeError: Cannot read property 'then' of undefined

This error occurs when you try to call the then method on a value that's not a promise. The then method is used to handle promise resolutions and rejections.

Why It Happens

You're trying to call then on a non-promise value.

How to Fix It

Make sure you're calling then on a promise. If you're trying to handle a non-promise value, use a different approach, such as if/else statements or conditional checks.


4. Async function was not awaited

This error occurs when you define an async function but don't call it with the await keyword. Async functions are designed to be used with the await keyword to pause the execution of the surrounding code.

Why It Happens

You're not calling your async function with the await keyword.

How to Fix It

Call your async function with the await keyword. For example, if you have an async function, call it like this: const result = await myAsyncFunction()


5. Promise is not a function

This error occurs when you try to call a promise as if it were a function. Promises are objects that represent the eventual completion (or failure) of an asynchronous operation.

Why It Happens

You're trying to call a promise as if it were a function.

How to Fix It

Make sure you're calling a function that returns a promise, not the promise itself. If you're trying to chain promises together, use the then method to handle the resolution or rejection of the promise.


6. TypeError: __await is only valid in async functions

This error occurs when you try to use the await keyword in a non-async function. The await keyword can only be used within an async function to pause the execution of the surrounding code.

Why It Happens

You're trying to use await in a non-async function or outside of a function altogether.

How to Fix It

Wrap the code that uses await in an async function. For example, if you have a non-async function that uses await, change it to an async function like this: async function myFunction() { await ... }

Conclusion

Async/await is a powerful feature in JavaScript that can make your code easier to read and maintain. However, it's not immune to errors. By understanding the causes and solutions to common async await errors, you can improve your application's performance and reliability. Remember to use async functions with the await keyword, handle promise rejections, and avoid calling promises as if they were functions. With practice and experience, you'll become more comfortable using async/await and writing robust asynchronous code.

Explore More Debugging Resources

- [Browse all JAVASCRIPT errors](/languages/javascript)

- [Browse errors by type](/error-types)

- [Search all documented errors](/search)

- [Use the Error Explainer](/error-explainer-tool)

Related JAVASCRIPT Articles

Have a specific error? Get an instant explanation.

Explain an Error