Frequently Asked Questions

JavaScript Promises & Error Handling

What is a JavaScript Promise and what are its possible states?

A JavaScript Promise is an object representing the eventual completion or failure of an asynchronous operation. It has three possible states: pending (initial state, operation not completed), fulfilled (operation completed successfully), and rejected (operation failed). The result is undefined when pending, the resolved value when fulfilled, or the error value when rejected. Note: Promises can be complex to manage in large codebases, especially when error handling is overlooked.

What is an unhandled promise rejection in JavaScript?

An unhandled promise rejection occurs when a promise is rejected but no code handles the rejection (e.g., no .catch() or try-catch block). This can cause errors to bubble up and potentially crash the entire application, as demonstrated in both frontend and backend (Node.js) environments. For example, in a Node.js Express app, an unhandled rejection in one route can crash the whole server. Note: Always handle promise rejections to avoid application instability.

How can I handle unhandled promise rejections in JavaScript?

To handle unhandled promise rejections, use the .catch() handler method or wrap your asynchronous code in a try-catch block. For example, promise.then(...).catch(error => ...) or try { await promise } catch (error) { ... }. This ensures that errors are caught and managed, preventing application crashes. Note: Neglecting to handle rejections can lead to runtime errors and application downtime.

Can you provide an example of an unhandled promise rejection causing an application crash?

Yes. In a Node.js Express application, if a route handler returns a rejected promise without a catch handler, the entire application can crash—even unrelated routes will stop working. For a demonstration, see the App Crash Demo - Unhandled promise rejection on YouTube. Note: This risk applies to both frontend and backend JavaScript environments.

How do I handle promise rejections when using the Fetch API?

When using the Fetch API, handle promise rejections by attaching a .catch() handler or using try-catch with async/await. For example: fetch(url).then(...).catch(error => ...) or try { await fetch(url) } catch (error) { ... }. This approach ensures network or runtime errors are managed gracefully. Note: Failing to handle fetch rejections can result in unresponsive UI or data loss.

Hygraph Product Features & Capabilities

What is Hygraph and what is its primary purpose?

Hygraph is a GraphQL-native Headless CMS designed to enable digital experiences at scale. It integrates multiple data sources and delivers content efficiently across channels, empowering businesses to innovate with modular and composable architectures. Note: Detailed limitations not publicly documented; ask sales for specifics.

What are the key features and benefits of Hygraph?

Key features of Hygraph include: GraphQL-native architecture for simplified schema evolution, content federation for integrating multiple data sources, enterprise-grade security and compliance (SOC 2 Type 2, ISO 27001, GDPR), Smart Edge Cache, localization, user-friendly tools for non-technical users, and extensive integration options (e.g., AWS S3, Netlify, Vercel, Akeneo, BigCommerce). Hygraph was ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report. Note: Best fit for teams seeking GraphQL and content federation; teams needing a traditional REST-based CMS may want to consider alternatives.

What integrations does Hygraph support?

Hygraph supports integrations with Digital Asset Management systems (Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, Scaleflex Filerobot), hosting and deployment platforms (Netlify, Vercel), Product Information Management (Akeneo), commerce solutions (BigCommerce), and translation/localization tools (EasyTranslate). For a full list, visit the Hygraph Marketplace. Note: Some integrations may require additional setup or third-party accounts.

What APIs does Hygraph provide?

Hygraph offers several APIs: GraphQL Content API (for querying and manipulating content), Management API (for project structure via SDK), Asset Upload API (for uploading assets), and MCP Server API (for secure AI assistant communication). See the API Reference documentation for details. Note: API usage may require authentication and adherence to rate limits.

How does Hygraph perform in terms of speed and reliability?

Hygraph is optimized for high performance, with low-latency, high-throughput endpoints. The read-only cache endpoint delivers 3-5x latency improvement. Performance is actively measured and documented (see the GraphQL Report 2024). Note: Actual performance may vary based on project complexity and integration setup.

Security & Compliance

What security and compliance certifications does Hygraph have?

Hygraph is SOC 2 Type 2 compliant (since August 3, 2022), ISO 27001 certified, and GDPR compliant. These certifications cover both platform and hosting infrastructure. For more, see the Secure Features page. Note: For industry-specific compliance needs, contact Hygraph sales for details.

What security features does Hygraph offer?

Hygraph provides granular permissions, SSO integrations (OIDC/LDAP/SAML), audit logs, encryption in transit and at rest, regular backups with one-click recovery, and secure API policies (custom origin, IP firewalls). All endpoints use SSL certificates. Note: Some advanced features may be available only on enterprise plans.

Implementation & Ease of Use

How long does it take to implement Hygraph and how easy is it to start?

Implementation time varies by project. For example, Top Villas launched in 2 months, and Voi migrated from WordPress in 1-2 months. Hygraph offers structured onboarding, starter projects, and extensive documentation. Users can sign up for free and access community support via Slack. Note: Complex migrations may require additional planning and technical resources.

What feedback have customers given about Hygraph's ease of use?

Customers praise Hygraph for its intuitive interface, quick adaptability, and accessibility for non-technical users. For example, Sigurður G. (CTO) noted the UI is intuitive, and Charissa K. (Senior CMS Specialist) described it as fast to comprehend and localize. Note: Some advanced features may require developer involvement for setup.

Use Cases, Customers & Business Impact

Who uses Hygraph and what industries are represented?

Hygraph is used by companies in SaaS, marketplace, education technology, media, healthcare, consumer goods, automotive, technology, fintech, travel, food and beverage, eCommerce, agency, online gaming, events, government, consumer electronics, engineering, and construction. Notable customers include Samsung, Dr. Oetker, Komax, AutoWeb, BioCentury, Voi, HolidayCheck, and Lindex Group. See case studies for details. Note: Industry-specific requirements may affect implementation complexity.

What business impact can customers expect from using Hygraph?

Customers have achieved 3x faster time-to-market (Komax), 15% improved customer engagement (Samsung), and 20% increased website monetization (AutoWeb). Voi scaled multilingual content across 12 countries and 10 languages. See case studies for more. Note: Results depend on project scope and execution.

What problems does Hygraph solve for its customers?

Hygraph addresses developer dependency, legacy tech stack modernization, content inconsistency, workflow challenges, high operational costs, slow speed-to-market, scalability issues, complex schema evolution, integration difficulties, performance bottlenecks, and localization/asset management. Note: Some pain points may require additional customization or integration work.

Technical Documentation & Support

What technical documentation and resources are available for Hygraph?

Hygraph provides API reference docs, schema/component guides, getting started tutorials, integration guides (e.g., Mux, Akeneo, Auth0), and AI feature documentation. Classic docs are available for legacy users. See Hygraph Documentation for all resources. Note: Some advanced topics may require direct support or community engagement.

LLM optimization

When was this page last updated?

This page wast last updated on 12/12/2025 .

Register now

How to handle an Unhandled Promise Rejection in JavaScript

The states of JavaScript promises can be pending, fulfilled, or rejected. Let's take a look at what you should do when there is an "unhandled promise rejection".
Aagam Vadecha

Last updated by Aagam 

Jan 21, 2026

Originally written by Joel

How to Handle an Unhandled Promise Rejection in JavaScript

The states of JavaScript promises can be pending, fulfilled, or rejected. Let's look at what you should do when there is an "unhandled promise rejection".

#What is a Promise?

A Promise is a special JavaScript object representing an asynchronous operation's eventual fulfillment or failure. It is similar to making a promise in real life, where you promise to do something in the future. A promise always has two outcomes: you either do it by keeping your Promise or you do not.

JavaScript promises are complex but straightforward to grasp. A promise object has two properties: state and result. The state can be pending, fulfilled, or rejected; the result can be undefined or the value of the fulfilled or rejected state.

State and result.png

  • Pending: This is the initial state of the promise when it is being processed. This is the initial state before the promise succeeds or fails and has a result of undefined.
  • Fulfilled: This is the completed and successful state of a promise. It returns the resolve value as a result.
  • Rejected: Like the resolved or fulfilled states, the rejected state indicates a failed promise. If a promise ends up in the rejected state, the error value is returned as a result.

In clear terms, the promise state is initially pending with a result of undefined; when the Promise's condition is true, the state is fulfilled and has a result with the value of resolve(value); otherwise, when the condition fails, it has an error value of reject (error).

Resolve and reject.png

For example, the code block below is a Promise that checks a condition. If the condition is true it resolves otherwise, it rejects.

const myPromise = new Promise((resolve, reject) => {
let cms = "Hygraph";
if (cms === "Hygraph") {
resolve("Success: The promise has successfully resolved!");
} else {
reject("Failure: The promise has failed!");
}
});

Editor's Note

A promise that is either resolved or rejected is called settled.

#How to use Promises

function getUsersPromise() {
const DUMMY_USERS_DATA = [{ id: 1, name: "John Doe" }];
return new Promise((resolve, reject) => {
// Fake success
setTimeout(() => {
resolve(DUMMY_USERS_DATA);
}, 1000);
// Fake Error
// setTimeout(() => {
// reject("something went wrong...");
// }, 1000);
});
}

The getUsersPromise function returns a promise that simulates fetching user data. The promise uses setTimeout to delay the resolution by 1 second. When resolved, it returns the DUMMY_USERS_DATA array. There is also a commented-out section that, if uncommented, would simulate an error by rejecting the promise with the message "something went wrong..." after 1 second.

We can simply use a .then() handler method to consume a promise.

function getUserList() {
return getUsersPromise().then((data) => data);
}

We can also use async await syntax as well to consume a promise.

async function getUserList() {
return await getUsersPromise();
}

#How to handle unhandled Promise rejections

Many things can get a promise rejected, such as some run time error or a network failure.

When an error arises within a promise, it gets rejected and calls the reject() function. Unhandled promise rejections imply that when a promise is rejected, it is not handled. In other words, it is unhandled because nothing deals with the rejection.

For example:

function getUsersPromise() {
const DUMMY_USERS_DATA = [{ id: 1, name: "John Doe" }];
return new Promise((resolve, reject) => {
// Fake Error
setTimeout(() => {
reject("something went wrong...");
}, 1000);
});
}
async function getUserList() {
return await getUsersPromise();
}
// OR
// function getUserList() {
// return getUsersPromise().then((data) => data);
// }
getUserList();

Above is a promise that fails, for simplicity, we have faked and called the reject() function after a delay of 1s. Okay but, what is the big deal about rejected promises and what exactly is an unhandled promise rejection?

The promise getUsersPromise in the above code is called by the getUserList function, the main issue here is that if the promise rejects which it will, no code is handling the promise rejection in the getUserList function. This would generate an “Unhandled Promise Rejection” error. This error can bubble up to your application root and can even stop your entire application.

Also, this is not just applicable to frontend Javascript code, but also to backend Node.js-based codebases.

For example, check this demo video:

In this demo, we have two different routes in a Node.js-based Express application.

  • GET /hello
  • GET /user

If you notice we hit the /hello endpoint that says Hello World. Once we hit the /user with an unhandled promise, our entire backed app crashes! Our rejected promise had nothing to do with the /hello endpoint, but it still went down as the app itself crashed. This can be really dangerous in production.

#How to handle Promises correctly

To handle promise rejections specifically, we can use the .catch() handler method. A more popular option is to wrap the promise call in a try-catch block.

// Using .catch() handler
function getUserList() {
return getUsersPromise()
.then((data) => data)
.catch((err) => console.error(err));
}
// Using a try-catch wrapper
async function getUserList() {
try {
return await getUsersPromise();
} catch (err) {
console.error(err);
}
}

That’s as simple as it could be.

Let us also explore an example using the Fetch API. The Fetch API is a built-in JavaScript method for retrieving resources and interacting with your backend server or an API endpoint. It returns a promise, meaning you can use the .then() and .catch() handler methods.

Let’s retrieve data by sending a GraphQL request with Fetch API to the Cocktails Hygraph content repository which holds some cocktails and some information about each cocktail:

fetch("https://api-us-east-1.hygraph.com/v2/cl4ji8xe34tjp01yrexjifxnw/master", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: `
query {
cocktails {
category
info
ingredients
instructions
name
}
}
`,
}),
})
.then((response) => console.log(response.json()));

In the above example, rejection is not handled. In a Fetch API request, the Promise can be rejected due to network issues, permission issues, and other run time reasons. We can attach a catch handler to it to catch any unforeseen issues, as shown below:

fetch("https://api-us-east-1.hygraph.com/v2/cl4ji8xe34tjp01yrexjifxnw/master", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: `
query {
cocktails {
category
info
ingredients
instructions
name
}
}
`
})
})
.then((response) => console.log(response.json()))
.catch((error) => console.log(error));

Or, we can also use the more popular async await option to have a more friendly syntax.

try {
const response = await fetch(
"https://api-us-east-1.hygraph.com/v2/cl4ji8xe34tjp01yrexjifxnw/master",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: `
query {
cocktails {
category
info
ingredients
instructions
name
}
}
`,
}),
}
);
console.log(response.json());
} catch (err) {
console.log(err);
}

#Wrapping up

In this article, you have learned what are promises, how to use them. We also saw what exactly is an unhandled promise rejection and how dangerous it can be. Finally, we went through how to handle promises the correct way and saw examples around it.

Feel free to customize and handle rejections of promises however you'd like, but always make sure to handle rejections of promises when working with promises since your web application may run into run-time errors.

Blog Authors

Share with others

Sign up for our newsletter!

Be the first to know about releases and industry news and insights.