<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Asermu</title>
    <description>The latest articles on DEV Community by Asermu (@asermu).</description>
    <link>https://dev.to/asermu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3856235%2Fc1fd129e-674b-4856-90e7-dbd5f5e102de.png</url>
      <title>DEV Community: Asermu</title>
      <link>https://dev.to/asermu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/asermu"/>
    <language>en</language>
    <item>
      <title>Sentry never ran on my Next.js server, and the dashboard looked fine</title>
      <dc:creator>Asermu</dc:creator>
      <pubDate>Sat, 31 Oct 2026 18:57:14 +0000</pubDate>
      <link>https://dev.to/asermu/sentry-never-ran-on-my-nextjs-server-and-the-dashboard-looked-fine-1gpa</link>
      <guid>https://dev.to/asermu/sentry-never-ran-on-my-nextjs-server-and-the-dashboard-looked-fine-1gpa</guid>
      <description>&lt;p&gt;I run &lt;a href="https://asermu.com" rel="noopener noreferrer"&gt;Asermu&lt;/a&gt;, a novel-writing app built with Next.js and deployed as a Docker image on Railway. I added Sentry a while ago. The dashboard stayed quiet, and I took that as good news.&lt;/p&gt;

&lt;p&gt;It wasn't. Today I found that &lt;strong&gt;server-side Sentry had never started in production&lt;/strong&gt;. Not once.&lt;/p&gt;

&lt;h2&gt;
  
  
  The clue
&lt;/h2&gt;

&lt;p&gt;I keep a flag-gated test route that reports a test error to Sentry on purpose. On the server runtime it returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"sent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"runtime"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nodejs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"eventId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"309ea78..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"flushOk"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;captureException&lt;/code&gt; happily handed back an event id. But &lt;code&gt;Sentry.flush()&lt;/code&gt; returned &lt;code&gt;false&lt;/code&gt;, and nothing arrived in Sentry. The same test on the edge runtime returned &lt;code&gt;flushOk: true&lt;/code&gt;, and its event showed up in Sentry.&lt;/p&gt;

&lt;p&gt;In 90 days, Sentry had received exactly one event: my own edge test. Zero real server errors is not the same as zero errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ruling out the network
&lt;/h2&gt;

&lt;p&gt;My first guess was Railway's outbound network. So I built the app locally with the production DSN:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;How I ran the same build&lt;/th&gt;
&lt;th&gt;&lt;code&gt;flushOk&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;next start&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.next/standalone/server.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Same build, same env, same machine. Only the server entry point changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cause
&lt;/h2&gt;

&lt;p&gt;The Docker image runs the standalone output (&lt;code&gt;output: "standalone"&lt;/code&gt;), which Next.js traces and copies into &lt;code&gt;.next/standalone&lt;/code&gt;. Comparing the two folders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.next/server/instrumentation.js&lt;/code&gt; — &lt;strong&gt;present&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.next/standalone/.next/server/instrumentation.js&lt;/code&gt; — &lt;strong&gt;missing&lt;/strong&gt;, along with the chunks it loads, including the one built from &lt;code&gt;sentry.server.config.ts&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;instrumentation.ts&lt;/code&gt; is where &lt;code&gt;register()&lt;/code&gt; imports the Sentry server config. With that file missing from the standalone build, &lt;code&gt;register()&lt;/code&gt; never runs, &lt;code&gt;Sentry.init()&lt;/code&gt; is never called on Node, and:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;captureException&lt;/code&gt; still returns an event id, but nothing is sent&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;flush()&lt;/code&gt; returns &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onRequestError&lt;/code&gt; reports nothing, so unhandled route errors vanish too&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Edge was fine because its instrumentation is bundled with the edge/middleware output, which standalone does include.&lt;/p&gt;

&lt;p&gt;This was Next.js 16.4.2 with Turbopack and &lt;code&gt;@sentry/nextjs&lt;/code&gt; 10.76.2. I haven't checked other versions, or whether it's already a known issue upstream.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Copy the missing server files into the standalone folder after the build, without overwriting anything Next.js chose to ship, and fail the build if the file is still missing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;npm run build
&lt;span class="c"&gt;# Standalone omits server/instrumentation.js and the chunks it loads.&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; .next/server &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'*.map'&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'*.nft.json'&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;--parents&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt; ../standalone/.next/server/ &lt;span class="se"&gt;\;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; ../standalone/.next/server/instrumentation.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a clean build that adds 7 files, about 1.5 MB. The &lt;code&gt;test -f&lt;/code&gt; guard matters: if a future Next.js version moves things around, the deploy fails loudly instead of silently shipping without error reporting again.&lt;/p&gt;

&lt;p&gt;After deploying, the server test returned &lt;code&gt;flushOk: true&lt;/code&gt;, and both a handled error and an unhandled route error showed up in Sentry.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell past me
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"No errors" is a claim you have to prove.&lt;/strong&gt; Fire a test error from every runtime (server, edge, browser) after you set up error tracking, and again after big upgrades.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check &lt;code&gt;Sentry.flush()&lt;/code&gt;'s return value&lt;/strong&gt; in a test route. An event id alone proves nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you deploy &lt;code&gt;output: "standalone"&lt;/code&gt;, compare it with &lt;code&gt;next start&lt;/code&gt;.&lt;/strong&gt; Same build, different entry point, different behaviour.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;I build Asermu, an offline-first novel-writing app with no AI writing features. I write here about the engineering behind it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
