Root CauseWhat broke, why, and the fix.

A posting runner retried after a timeout even though the post was already live

· debugging, automation, reliability
ⓘ Operated by TechAthletes. Every post here is a bug we hit in our own work — symptom, root cause, fix. Nothing is sponsored and we are not paid to mention any tool.

The timeout ended after the post was live

The scheduled posting runner used a simple success check: look for Tweet posted in the posting script’s stdout. If that text did not appear, the runner treated the post as unsuccessful and retried. After two unsuccessful attempts, it moved the text to the end of the queue.

On September 26, the runner recorded this error:

01:24 ERROR   attempts=[1:TIMEOUT,2:TIMEOUT] tail=TIMEOUT after 360s (process group killed)

The log described both attempts as timeouts. The next action was to rotate the text to the queue’s tail. From the runner’s perspective, there had been no successful post to remove from the queue.

The actual timeline showed something different. The post existed, with a creation time of 01:24:19. The pmset log placed the second attempt’s caffeinate interval at 01:18:21–01:24:20, corresponding to the recorded 360-second deadline. The post had succeeded one second before the process was killed.

That sequence changed the meaning of the error. The deadline had been reached, and the process group had been killed. But those facts did not establish that the external action had failed. The runner had recorded how the attempt ended without correctly establishing what the attempt had accomplished.

Looking further back exposed another mismatch. An attempt marked failed at 03:56 on September 23 had also produced a post. Its opening text was damaged: the initial A cl was missing, leaving it to begin oud of correlated data has a grain…. A complete version of the same content appeared again at 22:33 that day. The investigation recorded that duplicate posting had already happened twice.

Missing success output became permission to post again

The central assumption was that an absent success message meant an absent post. That assumption joined two separate questions: whether the script reported success, and whether the post existed.

The runner could observe the first through stdout. It was using that observation to answer the second.

In this incident, killing the Node process could destroy buffered output before the caller received it. The killed process could no longer finish reporting its result. The missing Tweet posted message therefore left several possibilities open: the attempt had failed, it had succeeded before being killed, or it had succeeded but its report had not arrived.

The runner collapsed those possibilities into failure. That classification supplied the justification for both retrying and rotating the queue.

Rotation was particularly misleading. Its comment said the action would also avoid duplicate posting after partial success. But rotation preserved the text as work still waiting to be done. If the post had already succeeded, moving its text to the tail made it eligible to appear again later.

The mechanism intended to avoid duplicates was consequently a source of duplicates. Changing the text’s position did not resolve whether it had already been published. It only postponed another attempt.

The September 26 timestamps made that distinction concrete. At the moment the runner lost the process, the external action had already happened. Keeping the text in the queue preserved an obligation that the timeline showed had already been fulfilled.

Other checks did not resolve the uncertainty

Two additional findings explained why other signals had not provided the protection they appeared to offer.

The retry log included strays_killed=8. That count had been interpreted as eight browser remnants from earlier attempts. Measurement showed that a single Chrome instance corresponded to nine processes matching the profile. A count of eight was therefore browser-sized; it did not establish that eight separate browser instances had accumulated.

This mattered to the interpretation of the incident. The cleanup count was a process count, and reading it as a count of abandoned browsers gave it a meaning the measurement did not support. It did not answer whether the post had succeeded.

The refill script also had a duplicate guard. It was designed to extract /a/<slug>/ values from posted.log, using those identifiers to recognize content already posted.

However, the POSTED entries truncated the body at 70 characters. The URL did not survive that truncation. Across 47 POSTED entries in the two logs, the guard recovered only one slug.

The guard existed, but the records it consumed usually lacked the information it needed. Its presence could not compensate for the runner’s incorrect failure classification.

Together, these findings kept the investigation focused on what the records actually established. The browser cleanup number did not describe eight old browsers. The duplicate guard did not have a usable identifier for nearly all the recorded posts. And a timeout did not establish that publication had failed.

The repair preserved evidence before deciding to retry

The changes focused on retaining enough evidence to make a decision after an interruption.

The posting script began appending its stages to a file: startup, login, composer, typing, and sending. Unlike buffered stdout lost with the process, the written record remained available after the kill. The caller could inspect it to determine whether the attempt had entered the sending window.

For an unsuccessful attempt that had reached that window, the runner would check the actual timeline before retrying. The result had three possible states:

FOUND
NOTFOUND
UNKNOWN

FOUND meant the post existed, so the runner should not post it again. NOTFOUND meant the timeline had been read successfully and the post was absent, permitting a retry. UNKNOWN meant the timeline could not be read, so nothing should move.

That last state was the missing distinction. An unsuccessful check was no longer treated as a successful check that found nothing. Uncertainty no longer supplied permission to retry or rotate.

The deadline handling changed too. If the deadline arrived during sending, the runner would wait 75 seconds instead of immediately killing the process. This gave the sending stage additional time rather than cutting it off at the original deadline.

The login budget was also reduced. Its previous worst case was 294 seconds against the 360-second deadline, leaving little room for sending. The revised budget was 166 seconds; the measured normal login time was 2.0 seconds.

Finally, the script began reading back the composed text before sending and comparing it with the intended text. If the beginning was missing, it would type the text again once. If the mismatch remained, it would not send. This addressed the damaged opening found in the earlier post.

Check what your timeout actually proves

The lesson is to inspect the evidence behind the transition from an interrupted attempt to another external action.

In your own runner, find the condition that authorizes a retry. If it is the absence of a success message, check whether that condition can distinguish a failed action from a completed action whose report never arrived. In this incident, it could not.

Then inspect what survives termination. The stage file gave the caller evidence about whether sending had begun. The timeline check supplied evidence about whether publication had happened. Those records answered different questions, and the repair used both.

Check queue handling as well. Moving an item to the tail still leaves it eligible for execution. If an uncertain attempt may already have succeeded, rotation does not settle that uncertainty.

Finally, examine the records used by duplicate protection. Here, truncating logged text removed the URL that the guard depended on. Comparing the expected identifier with actual log entries exposed the gap.

The process had been killed, but the post was live. The correction was to preserve that possibility in the runner’s decisions: when the outcome could not be established, record it as unknown and leave the work in place.

Root Cause is written while shipping small software products — you can see them at TechAthletes.

All posts →

Get new posts by email

We email you only when a new post goes up here. You can unsubscribe at any time.

Privacy policy