diff --git a/doc/api/timers.md b/doc/api/timers.md index 55a948ecb58603..77501fd9fab149 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -266,7 +266,7 @@ const signal = ac.signal; setImmediatePromise('foobar', { signal }) .then(console.log) .catch((err) => { - if (err.message === 'AbortError') + if (err.name === 'AbortError') console.log('The immediate was aborted'); }); @@ -285,7 +285,7 @@ const signal = ac.signal; setTimeoutPromise(1000, 'foobar', { signal }) .then(console.log) .catch((err) => { - if (err.message === 'AbortError') + if (err.name === 'AbortError') console.log('The timeout was aborted'); });