<?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: Dhivakar R</title>
    <description>The latest articles on DEV Community by Dhivakar R (@dhivakar1010).</description>
    <link>https://dev.to/dhivakar1010</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%2F4276347%2Fa040d776-4724-43d3-85a1-2e5d03e969b7.jpg</url>
      <title>DEV Community: Dhivakar R</title>
      <link>https://dev.to/dhivakar1010</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhivakar1010"/>
    <language>en</language>
    <item>
      <title>My app promo videos are 100% code. Even the music.</title>
      <dc:creator>Dhivakar R</dc:creator>
      <pubDate>Wed, 02 Dec 2026 22:05:15 +0000</pubDate>
      <link>https://dev.to/dhivakar1010/my-app-promo-videos-are-100-code-even-the-music-1ena</link>
      <guid>https://dev.to/dhivakar1010/my-app-promo-videos-are-100-code-even-the-music-1ena</guid>
      <description>&lt;p&gt;Every promo video for my apps is a React project, a JSON file and a build script. The scenes, the narration, the timing and the background music all come out of code, and one command renders the landscape and portrait cuts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwu3r2j8o8eyflis1ir06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwu3r2j8o8eyflis1ir06.png" alt="The promo pipeline: script, voice, timeline, render" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I run Dhiva Labs as a solo developer, and I ship a lot of apps. Recording a screen and talking over it does not scale to that, and it does not survive a copy change. The pipeline below made the ApiWorkbench video, and I have copied it to the other apps since.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scenes are React components
&lt;/h2&gt;

&lt;p&gt;The video is built with Remotion, which renders React components to frames. A scene is a component. A transition is a prop. Colours come from one theme file, which I fill from the app's own theme so the video looks like the product. The ApiWorkbench palette in &lt;code&gt;src/theme.ts&lt;/code&gt; is the teal-dark theme from the app's &lt;code&gt;lib/theme.dart&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;C&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'#061012'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;panel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'#0D1B1E'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tealBright&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'#2EC8BE'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'#EAF6F5'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fonts live in &lt;code&gt;public/fonts&lt;/code&gt; and load from there, because a render that waits on Google Fonts can time out in the middle of a frame.&lt;/p&gt;

&lt;h2&gt;
  
  
  The narration is one JSON file
&lt;/h2&gt;

&lt;p&gt;Every spoken line is an entry in &lt;code&gt;vo-script.json&lt;/code&gt;:&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="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"privacy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"say"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"No accounts. No analytics. No telemetry. It only sends the requests you make."&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the sentence, run &lt;code&gt;npm run voiceover&lt;/code&gt;, and the clip, its duration and its transcript are regenerated. Clips are cached by a hash of the text, voice and lexicon, so only changed lines are regenerated.&lt;/p&gt;

&lt;h2&gt;
  
  
  An offline voice, and why the first one was dropped
&lt;/h2&gt;

&lt;p&gt;The voice is Kokoro, running locally through sherpa-onnx, with the &lt;code&gt;af_heart&lt;/code&gt; speaker. Nothing is sent to a cloud service.&lt;/p&gt;

&lt;p&gt;It was not my first choice. My first try used Piper with espeak, and it pronounced "API" as "IPI". For an API client that is disqualifying, and I dropped it. Kokoro gets the acronyms right once you pin them. A &lt;code&gt;pronunciations.txt&lt;/code&gt; lexicon sits ahead of the model's own, so my entries win:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api ˌ A p ˌ i ˈ I
mqtt ˈ ɛ m k j ˌ u t ˌ i t ˈ i
grpc ʤ ˌ i ˌ ɑ ɹ p ˌ i s ˈ i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Whisper checks every clip
&lt;/h2&gt;

&lt;p&gt;A voice that sounds right to me at midnight is not a test. In the same &lt;code&gt;npm run voiceover&lt;/code&gt; step, every generated clip goes through Whisper (the &lt;code&gt;tiny.en&lt;/code&gt; model, also through sherpa-onnx), and the transcript is compared with what the script says. A clip is flagged when fewer than 80 percent of its words come back, or when the word "api" goes missing.&lt;/p&gt;

&lt;p&gt;That check found two real problems. A list of protocols was being misheard until I added the Oxford comma, so the script now reads "REST, GraphQL, MQTT, WebSockets, server-sent events, and gRPC". And "MQTT" immediately after "WebSockets" was swallowed, so MQTT goes first. Both fixes are visible in the script today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fykbsocwq7lzkx5bcrlgj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fykbsocwq7lzkx5bcrlgj.png" alt="A frame from the load-test scene" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The whine, and the notches
&lt;/h2&gt;

&lt;p&gt;The int8 Kokoro model has a flaw: whenever it speaks, there are pure tones at sampleRate/5 and twice that, which is 4.8 and 9.6 kHz at 24 kHz. I heard an annoying high pitch before I could name it. The fix is in &lt;code&gt;tools/voiceover.cjs&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;deTone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9600&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9600&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`bandreject=f=${f}:width_type=h:w=${f &amp;lt; 9000 ? 70 : 90}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two narrow ffmpeg &lt;code&gt;bandreject&lt;/code&gt; notches, each applied twice for depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timing comes from the audio, not from guesses
&lt;/h2&gt;

&lt;p&gt;I never type a scene length. Each clip's duration is measured after the audio is trimmed and normalised, and &lt;code&gt;src/timeline.ts&lt;/code&gt; lays out the scenes from those numbers. A scene is as long as its narration plus a lead and a tail that keep it clear of the transitions. One scene is marked &lt;code&gt;fill&lt;/code&gt;, and it absorbs whatever is left, so every cut is exactly 90 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;FPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;TOTAL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;FPS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Animations sync to words, not to frame numbers. Inside a scene, &lt;code&gt;cue('word')&lt;/code&gt; returns the frame where that word is spoken:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;errorAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rage&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;cue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'just'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The error banner appears on the word, and if I rewrite the sentence, it moves with it. If the words change so that the cue word is gone, the build throws, instead of rendering a mistimed video.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the music is composed by a script
&lt;/h2&gt;

&lt;p&gt;This is the part I learned the hard way. I used a stock track from a "free" music library under one of my ApiWorkbench Shorts, and the video was blocked worldwide by a Content ID claim.&lt;/p&gt;

&lt;p&gt;So now the music is original. &lt;code&gt;tools/compose.cjs&lt;/code&gt; synthesises it from scratch, with no samples: band-limited sawtooth pads, Karplus-Strong plucks, bass and light drums over a four-chord loop, with a Schroeder reverb and kick ducking. The noise is seeded, so every run produces an identical track:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Deterministic noise so every render of the track is identical.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;seed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12345&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nobody can claim a track that does not exist anywhere else. It also lives in the repo, so a new cut never needs a licence check.&lt;/p&gt;

&lt;h2&gt;
  
  
  One command
&lt;/h2&gt;

&lt;p&gt;The loop is: edit &lt;code&gt;vo-script.json&lt;/code&gt; or the scene definitions, run &lt;code&gt;npm run voiceover&lt;/code&gt;, run &lt;code&gt;npm run stills&lt;/code&gt; for contact sheets to review, then render everything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run render:all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That renders the Problem Stack and Rage Hook cuts, each in landscape and portrait, with &lt;code&gt;--crf=17&lt;/code&gt;. Portrait is its own composition, not a crop of the landscape one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would copy first
&lt;/h2&gt;

&lt;p&gt;If you want to build this, start in this order: the narration JSON, then the Whisper check, then timing from clip lengths. Those three remove most of the hand-editing. The music script is the last piece, and the one I would have written first if I had known about Content ID.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant and checked every claim and code excerpt against the source.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>remotion</category>
      <category>react</category>
      <category>ffmpeg</category>
      <category>automation</category>
    </item>
    <item>
      <title>8 pull requests in 48 hours: what I fixed in Monero's light-wallet server</title>
      <dc:creator>Dhivakar R</dc:creator>
      <pubDate>Wed, 02 Dec 2026 22:04:08 +0000</pubDate>
      <link>https://dev.to/dhivakar1010/8-pull-requests-in-48-hours-what-i-fixed-in-moneros-light-wallet-server-44bl</link>
      <guid>https://dev.to/dhivakar1010/8-pull-requests-in-48-hours-what-i-fixed-in-moneros-light-wallet-server-44bl</guid>
      <description>&lt;p&gt;My first contribution to monero-lws was eight pull requests, and all eight were merged within two days. Here is what was broken, how I found it, and what the maintainer's reviews taught me about getting fixes accepted upstream.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb9acplnp1rl2iq53r0hk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb9acplnp1rl2iq53r0hk.png" alt="Eight merged pull requests against vtnerd/monero-lws" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What monero-lws is
&lt;/h2&gt;

&lt;p&gt;monero-lws is the Monero Light Wallet Server: it scans the chain for the view keys of many accounts at once, keeps the results in an LMDB database, and serves them to wallets through the MyMonero API. The wallet does not have to scan the chain itself. The server has to keep every account moving, so a stall or a lost index entry is a real bug for its users.&lt;/p&gt;

&lt;p&gt;I run Dhiva Labs as a solo developer. I decided to improve this server upstream instead of writing my own. I cloned it, built it in Debug and Release, and went through the issue tracker for bugs I could reproduce. The eight PRs are #307 to #314, all against &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc0mmgro7ojsqc21wl6fj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc0mmgro7ojsqc21wl6fj.png" alt="The bug, in the diff" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The timeout that grew: #311
&lt;/h2&gt;

&lt;p&gt;The most satisfying bug was in &lt;code&gt;do_wait()&lt;/code&gt; in &lt;code&gt;src/rpc/client.cpp&lt;/code&gt;. It waits on a ZeroMQ socket with &lt;code&gt;zmq_poll()&lt;/code&gt;, and when a signal interrupts the poll (&lt;code&gt;EINTR&lt;/code&gt;) it retries with whatever time is left. The code that computed the time spent looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;chrono&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;steady_clock&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ready&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;zmq_poll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;chrono&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;steady_clock&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;spent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;chrono&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;duration_cast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;chrono&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;milliseconds&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;timeout&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read the subtraction again: &lt;code&gt;start - end&lt;/code&gt;. That is negative. So &lt;code&gt;timeout -= spent&lt;/code&gt; made the remaining timeout larger after every interrupted poll. As long as signals kept arriving, the wait never ran out. The line had been there since the initial commit, and it only mattered on &lt;code&gt;EINTR&lt;/code&gt;, which is why nobody had hit it in normal use.&lt;/p&gt;

&lt;p&gt;My first fix was to swap the operands. The reviewer asked me to take &lt;code&gt;start&lt;/code&gt; once before the loop, so each poll gets &lt;code&gt;timeout&lt;/code&gt; minus the time since the first call. The merged diff:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gi"&gt;+      // retries (EINTR, ignored signals) wait only for what is left of `timeout`&lt;/span&gt;
&lt;span class="gi"&gt;+      const auto start = std::chrono::steady_clock::now();&lt;/span&gt;
       for (;;)
       {
&lt;span class="gd"&gt;-        const auto start = std::chrono::steady_clock::now();&lt;/span&gt;
&lt;span class="gd"&gt;-        const int ready = zmq_poll(items, 2, timeout.count());&lt;/span&gt;
&lt;span class="gd"&gt;-        const auto end = std::chrono::steady_clock::now();&lt;/span&gt;
&lt;span class="gd"&gt;-        const auto spent = std::chrono::duration_cast&amp;lt;std::chrono::milliseconds&amp;gt;(start - end);&lt;/span&gt;
&lt;span class="gd"&gt;-        timeout -= std::min(spent, timeout);&lt;/span&gt;
&lt;span class="gi"&gt;+        const auto spent =&lt;/span&gt;
&lt;span class="gi"&gt;+          std::chrono::duration_cast&amp;lt;std::chrono::milliseconds&amp;gt;(std::chrono::steady_clock::now() - start);&lt;/span&gt;
&lt;span class="gi"&gt;+        const int ready = zmq_poll(items, 2, (timeout - std::min(spent, timeout)).count());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test matters as much as the fix. It installs a no-op &lt;code&gt;SIGUSR1&lt;/code&gt; handler, queues a request on the client's REQ socket so &lt;code&gt;get_message()&lt;/code&gt; has something to wait for, and then sends &lt;code&gt;SIGUSR1&lt;/code&gt; to the waiting thread every 50 ms for two seconds, while &lt;code&gt;get_message()&lt;/code&gt; waits one second for a reply that never comes. The expectation is &lt;code&gt;daemon_timeout&lt;/code&gt; in under 2.5 seconds. Before the fix the call took 5,109 ms. After it, the test passes in under 2.5 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  New accounts that waited for the next block: #310
&lt;/h2&gt;

&lt;p&gt;Issue #306 reported that new accounts showed zero outputs. I reproduced a stall on regtest. A scan thread that is already at the tip sits in &lt;code&gt;wait_for_block()&lt;/code&gt;, and an account pushed to that thread was not read until the next block arrived, or until the four-minute &lt;code&gt;--sub&lt;/code&gt; timeout. On a busy server every thread already has accounts, so every new account waited. In my run it took three minutes and one hand-mined block before the account was picked up.&lt;/p&gt;

&lt;p&gt;My first version polled: it waited in one-second slices and checked a queue. The maintainer requested changes the same day. No polling, he said; use the ZMQ signalling that is already there. He was right, and I reworked it that day. Now the process publishes an &lt;code&gt;"ACCOUNT"&lt;/code&gt; message on the internal signal socket, and scan threads opt in to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kd"&gt;constexpr&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;account_change_signal&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ACCOUNT"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account_changes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lws&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;account_list_change&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// only `wait_for_block` reports this&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only &lt;code&gt;wait_for_block&lt;/code&gt; reports the change; &lt;code&gt;get_message&lt;/code&gt; and &lt;code&gt;send&lt;/code&gt; ignore it. After the change, the same repro showed the new account being scanned 7.4 seconds after &lt;code&gt;/login&lt;/code&gt;, bounded by the existing ten-second account poll.&lt;/p&gt;

&lt;p&gt;One honest limit: I never reproduced missed outputs, only the stall. I said so in the PR and let the reporter confirm.&lt;/p&gt;

&lt;h2&gt;
  
  
  The root cause of issue #225: #312
&lt;/h2&gt;

&lt;p&gt;Issue #225 is an &lt;code&gt;MDB_NOTFOUND&lt;/code&gt; error ("Failed to update accounts on disk") after a large resync, with hundreds of accounts stuck at random heights. The cause I found is in &lt;code&gt;change_height&lt;/code&gt;, used by rescan and import. It lowered the account's &lt;code&gt;scan_height&lt;/code&gt; with &lt;code&gt;std::min&lt;/code&gt;, but then re-inserted the height index entry at the requested height:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;-      user-&amp;gt;scan_height = std::min(height, user-&amp;gt;scan_height);&lt;/span&gt;
&lt;span class="gi"&gt;+      const block_id new_height = std::min(height, current_height);&lt;/span&gt;
&lt;span class="gi"&gt;+      user-&amp;gt;scan_height = new_height;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;-      key = lmdb::to_val(height);&lt;/span&gt;
&lt;span class="gi"&gt;+      // index must match `scan_height`, which never moves forward here&lt;/span&gt;
&lt;span class="gi"&gt;+      key = lmdb::to_val(new_height);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the requested height is above the account's current one, the account row and its index entry disagree. A later lookup by &lt;code&gt;scan_height&lt;/code&gt; finds nothing. Two new test sections, rescan and import above &lt;code&gt;scan_height&lt;/code&gt;, fail without the fix. Databases that are already inconsistent are not repaired by this change; the PR says so and offers a repair path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assert-only bugs: #307 and #314
&lt;/h2&gt;

&lt;p&gt;Two bugs only showed up in a Debug build, because upstream CI built Release only, where &lt;code&gt;assert&lt;/code&gt; compiles away. In #307 one assert used a variable name that no longer existed, and another was a bogus element-count check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;-          assert(sizeof(G) + uoffset &amp;lt;= end - pos);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;-      assert(thread_count || !lws_server_addr.empty());&lt;/span&gt;
&lt;span class="gi"&gt;+      assert(thread_count || !lws_server.address.empty());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fixing the code was half the job. #314 adds a CI job that builds Debug and runs the unit tests, so the next one is caught automatically. One detail from its comment: shared libraries, the Debug default, do not link here, so the job passes &lt;code&gt;-DBUILD_SHARED_LIBS=OFF&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flyk1oymy2976p1vz65ag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flyk1oymy2976p1vz65ag.png" alt="All eight pull requests" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The other three: #308, #309, #313
&lt;/h2&gt;

&lt;h1&gt;
  
  
  308 stops the &lt;code&gt;/feed&lt;/code&gt; WebSocket from starting two &lt;code&gt;async_close&lt;/code&gt; calls on one stream, which happened when shutting down the subscriber re-entered &lt;code&gt;close_check&lt;/code&gt; from &lt;code&gt;zmq_loop&lt;/code&gt;. #309 fixes issue #279 by decrypting encrypted payment IDs per account, with a new unit test; on review the maintainer asked for the test to move to &lt;code&gt;tests/unit/util&lt;/code&gt;, which I did, making the helper an object library so the static linker keeps the test case. #313 adds &lt;code&gt;webhook_add&lt;/code&gt; and &lt;code&gt;webhook_list&lt;/code&gt; to &lt;code&gt;monero-lws-admin&lt;/code&gt;, so webhooks can be managed from the command line.
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What I would tell anyone sending fixes upstream
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Build the configuration CI does not.&lt;/strong&gt; Both #307 and #314 exist because I ran the tests in Debug before every PR. Upstream had a blind spot, and I only found it by looking where CI did not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write the test that fails first.&lt;/strong&gt; The EINTR test turns a vague "timeouts feel long" into 5,109 ms against a 2.5 second limit. Maintainers merge numbers faster than opinions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State what you did not reproduce.&lt;/strong&gt; In #310 I said I saw the stall, not the missed outputs. It built trust for the review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Take the review as the design.&lt;/strong&gt; The polling version worked. The ZMQ version fits the codebase. Reworking it the same day kept the PR moving.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep each PR to one bug.&lt;/strong&gt; Eight focused PRs were reviewed and merged in two days, each one easy to judge on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Answer in the thread, push extra commits.&lt;/strong&gt; The maintainer squash-merges, so a follow-up commit is cleaner than rewriting history.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The code is public in &lt;a href="https://github.com/vtnerd/monero-lws" rel="noopener noreferrer"&gt;vtnerd/monero-lws&lt;/a&gt;, and the eight PRs are #307 to #314.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I wrote this with help from an AI assistant and checked every claim and code excerpt against the source.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>monero</category>
      <category>cpp</category>
      <category>opensource</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
