Urgent.News

What's breaking now, across thousands of outlets.

Tech

48-Hour Field Notes: My Output File Looked Complete Because I Streamed Straight Into It

A batch job that writes one JSON document per item sounds like the safest code you will write all week, right? No shared state, no transactions, no concurrent writers, just open() , write() , close() . So why did I spend most of two days chasing a downstream consumer that kept failing on files which were, by every check I had, present and readable? Here is the short version: my writer streamed…

The author discovered that a batch job writing JSON documents per item, streaming model output directly into the destination path, led to unexpected failures. The resume logic treated the existence of a file as completion, causing issues when the process died mid-stream. The writer concatenated chunks of structured text, creating a valid sequence of lines even if the file was cut at 60%.

The downstream consumer read four records instead of six and reported success. The author identified two distinct bugs that compounded each other. The first bug was truncated output that still parsed, while the second was a resume logic that skipped the damage. The first bug resulted from writing to the file directly, while the second was due to checking for the file's existence instead of validating its content.

The author shared a harness they created to reproduce the failures and fix the issues. They recommended writing to a temporary file with the .part extension, flushing it to disk, and then renaming it to the final destination. Additionally, they suggested validating the content of the temporary file before promoting it to the final location.

To ensure the fix works, they suggested running a crash test by killing the worker mid-stream and asserting that the destination file never appeared.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Did I forget something? A short about the to-dos that sink into old daily notes, and the Dataview query that finds them

Rozz Queries is a new three-part set of Rozz shorts, each one built around a single query from our free Dataview pack. Episode 1 is about the to-do you wrote in a daily note last week that's now…

  • "Rozz Queries" is a three-part series focusing on Dataview queries
  • Episode "The To-Do You Forgot" highlights forgotten daily tasks query
  • Query finds uncompleted tasks from last 14 days in daily notes folder

Inside GitHub’s new Git storage architecture

GitHub's new Git storage architecture is built so thousands of agents can push to a single repository at once. Here's how it works. The post Inside GitHub’s new Git storage architecture appeared first on The GitHub Blog .

Meta Releases Mac Version of Edits

From Instagram’s Edits blog: I’m Brett Westervelt, and I lead the Edits app. In just over a year, 50 million people have made Edits part of how they bring ideas to life, and we’re excited to expand what Edits can do for creators. Today we’re bringing Edits to the big screen.

More from Thursday 5 November →