The error that never reaches catch: how Promise.try catches it in JS
Promise.try calls your function straight away and puts its result in a promise, whether it returns a value, throws, or returns a promise. So a synchronous error reaches the same catch as an async one.

You have a function that takes a callback from whoever uses it, puts the result in a promise and carries on with .then() and .catch(). One day the callback throws before it returns anything, and the error never reaches .catch(). This article shows you why that happens, and how Promise.try closes the gap in one line.
What is Promise.try?
Promise.try is a static JavaScript method that takes any callback, synchronous or asynchronous, returning a value or throwing, and puts its result in a promise. So you have one way in, and the way out is always a promise.
According to the MDN page on Promise.try, the returned promise is fulfilled if the function returns a value, rejected if it throws, and waits if it returns a promise.
Why isn't Promise.resolve(func()) enough?
Promise.resolve(func()) isn't enough because func() runs before the promise exists. If it throws synchronously, the error escapes the whole line, and you never get a rejected promise.
Promise.resolve(loadConfig()).catch(handleError);The old fix was try...catch around the line, but try...catch is not an expression, so you can't use it where a value goes, like when you pass it to a function. The other fix was new Promise((resolve) => resolve(func())), which catches the error, but always creates a new promise even if the function already returned one.
How does Promise.try solve it?
Promise.try calls the function right away inside itself, so any synchronous error becomes a rejected promise instead of escaping. The result flows down the same chain, so synchronous and asynchronous errors reach the same .catch().
function runTask(task) {
return Promise.try(task)
.then((result) => console.log(result))
.catch((error) => console.error(error))
.finally(() => console.log("done"));
}This function works correctly whether task returns a value, throws, or is async and returns or throws. And if the function needs arguments, pass them right after it: Promise.try(loadUser, userId), without wrapping it in another function.
How is it different from Promise.resolve().then(func)?
The difference is that .then(func) calls the function later, asynchronously, while Promise.try calls it right away. So if the function reads or changes something at that moment, the result can differ between the two.
If you work with promises a lot, the article on Promise.withResolvers covers the same idea from the other side: how to create a promise and settle it from outside.
Where do you start now?
The lesson for us as developers: if your code calls a function whose shape you don't know, wrap it in Promise.try, because a synchronous error doesn't find its way to .catch() on its own. Search your code for Promise.resolve( in front of a function call, and try swapping it.
MDN says the feature is Baseline 2025, working in the latest browsers since January 2025, so if you must support older browsers, check your audience first. For error handling in network requests, see the article on fetch timeouts with AbortSignal, and for a wider learning plan, the Programmer Roadmap 2026. Where in your code is there a function that takes a callback you don't know will throw?
FAQ
What's the difference between Promise.try and Promise.resolve().then(func)?
The second one calls the function later, asynchronously, while Promise.try calls it straight away and settles the promise at once when it can.
Can I use it in the browser today?
Yes in modern browsers. MDN says it works in the latest browsers since January 2025, and it might not work on older devices or browsers.
Does it replace async and await?
No. It helps when you wrap a function that may or may not be synchronous and you want the result as a promise in one expression, like when you pass it to another function.


