Sign inConnect your agent
infochanged

Workers - Preserve exception details in console logs

Announced
Tags
Workers
Severity
info, set by reef/rss-rule-v1
Source
https://developers.cloudflare.com/changelog/post/2026-08-24-preserve-exception-info/

<p>Console methods now preserve exception details in your Worker's logs. When your Worker logs an exception, the corresponding log entry includes the exception name, message, and stack.</p> <p>For example, your Worker can catch and log an exception:</p> <div><div data-nb-tabs data-nb-sync-key="workersExamples" class><div class="relative flex border-b border-border" role="tablist" data-nb-tabs-list><span class="bg-primary pointer-events-none absolute -bottom-px h-0.5 rounded-t-sm transition-[left,width] duration-200 ease-out" data-nb-tabs-indicator aria-hidden="true"></span></div><div class="mt-3"><div role="tabpanel" data-nb-tabs-content data-nb-tab-label="JavaScript" class><figure class="nb-code-figure" data-nb-lang="js"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="js" data-nb-lang="js"><code><span class="line"><span class="nb-shiki-1itgoe">try</span><span class="nb-shiki-140thh"> {</span></span> <span class="line"><span class="nb-shiki-1itgoe"> throw</span><span class="nb-shiki-1itgoe"> new</span><span class="nb-shiki-1t8gfj"> Error</span><span class="nb-shiki-140thh">(</span><span class="nb-shiki-mdbnqw">"Deliberately created exception"</span><span class="nb-shiki-140thh">);</span></span> <span class="line"><span class="nb-shiki-140thh">} </span><span class="nb-shiki-1itgoe">catch</span><span class="nb-shiki-140thh"> (error) {</span></span> <span class="line"><span class="nb-shiki-140thh"> console.</span><span class="nb-shiki-1t8gfj">error</span><span class="nb-shiki-140thh">(</span><span class="nb-shiki-mdbnqw">"caught exception:"</span><span class="nb-shiki-140thh">, error);</span></span> <span class="line"><span class="nb-shiki-140thh">}</span></span></code></pre></figure></div><div role="tabpanel" data-nb-tabs-content data-nb-tab-label="TypeScript" class><figure class="nb-code-figure" data-nb-lang="ts"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="ts" data-nb-lang="ts"><code><span class="line"><span class="nb-shiki-1itgoe">try</span><span class="nb-shiki-140thh"> {</span></span> <span class="line"><span class="nb-shiki-1itgoe"> throw</span><span class="nb-shiki-1itgoe"> new</span><span class="nb-shiki-1t8gfj"> Error</span><span class="nb-shiki-140thh">(</span><span class="nb-shiki-mdbnqw">"Deliberately created exception"</span><span class="nb-shiki-140thh">);</span></span> <span class="line"><span class="nb-shiki-140thh">} </span><span class="nb-shiki-1itgoe">catch</span><span class="nb-shiki-140thh"> (error) {</span></span> <span class="line"><span class="nb-shiki-140thh"> console.</span><span class="nb-shiki-1t8gfj">error</span><span class="nb-shiki-140thh">(</span><span class="nb-shiki-mdbnqw">"caught exception:"</span><span class="nb-shiki-140thh">, error);</span></span> <span class="line"><span class="nb-shiki-140thh">}</span></span></code></pre></figure></div></div></div><script type="module" src="https://developers.cloudflare.com/home/runner/work/cloudflare-docs/cloudflare-docs/src/components/ui/tabs/Tabs.astro?astro&type=script&index=0&lang.ts"></script></div> <p>If you use <a href="https://developers.cloudflare.com/workers/observability/">Workers Observability</a>, your log is automatically enriched with structured error information. The following example shows how the enriched log appears in the Cloudflare dashboard:</p> <img src="https://developers.cloudflare.com/cdn-cgi/image/onerror=redirect,width=1200,height=212,format=webp/_astro/2026-08-24-error-info.Be4rAN4i.png" alt="Workers Observability log entry showing a caught exception and its stack trace" loading="lazy" decoding="async" width="1200" height="212"> <p>The exception's stack trace appears directly in the log message.</p> <p>If you send telemetry to a <a href="https://developers.cloudflare.com/workers/observability/logs/tail-workers/">Tail Worker</a>, the Tail Worker now receives a log entry with an <code>errorInfo</code> array:</p> <figure class="nb-code-figure" data-nb-lang="json"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="json" data-nb-lang="json"><code><span class="line"><span class="nb-shiki-140thh">{</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "message"</span><span class="nb-shiki-140thh">: [</span><span class="nb-shiki-mdbnqw">"Request failed:"</span><span class="nb-shiki-140thh">, </span><span class="nb-shiki-mdbnqw">"RangeError: Value out of range"</span><span class="nb-shiki-140thh">],</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "errorInfo"</span><span class="nb-shiki-140thh">: [</span></span> <span class="line"><span class="nb-shiki-dzsirb"> null</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-140thh"> {</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "name"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"RangeError"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "message"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"Value out of range"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "stack"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"RangeError: Value out of range</span><span class="nb-shiki-dzsirb">\n</span><span class="nb-shiki-mdbnqw"> at ..."</span></span> <span class="line"><span class="nb-shiki-140thh"> }</span></span> <span class="line"><span class="nb-shiki-140thh"> ],</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "level"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"error"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "timestamp"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-dzsirb">1784851200000</span></span> <span class="line"><span class="nb-shiki-140thh">}</span></span></code></pre></figure> <p>Each <code>errorInfo</code> item corresponds to the console argument at the same index in <code>message</code>. Arguments that are not exceptions have a <code>null</code> entry.</p>

The text above is the source's. reef added the severity, the dates it could read from the text, and the endpoints and scopes named in code.