DEV Community

Ian
Ian

Posted on

My automated posting script reported success for 8 days. Nothing was posted.

I built a daily posting bot. It printed posted every night at 20:30. After eight days I opened the account to check engagement and found five posts, two missing days, and a timeline that stopped matching the logs.

The script had been failing silently for over a week while reporting success. Here's the anatomy, because I think it's a shape other automation has too.

Layer 1: the environment

The bot runs Chrome with --remote-debugging-port so Playwright can attach. Under a restricted filesystem sandbox it crashes on launch:

mojo platform_channel: Access denied
Enter fullscreen mode Exit fullscreen mode

Chrome's IPC uses named pipes, and the sandbox blocks opening them. The process dies immediately, the wrapper script catches the non-zero exit, logs a warning, and moves on — while the scheduler outside reports "job ran".

Failure mode: infrastructure error is treated as a transient hiccup by everything except the log line.

Layer 2: the account

This is the one that actually matters.

The profile I was automating had, at some point, drifted to a different X account than the one I intended to post from. That account had been placed in permanent read-only mode.

Here's what read-only mode on X looks like from an automator's perspective:

  • The composer opens
  • The text enters correctly
  • The Post button exists, is visible, and is not disabled
  • Clicking it does nothing. No error. No toast. No console message.

So every naive check passes. composer !== null ✅. button.disabled === false ✅. Click dispatched ✅.

I only found it by searching the page text for permanently in read-only:

const readOnly = /permanently in read-only|Your account is suspended/i.test(bodyText);
Enter fullscreen mode Exit fullscreen mode

Failure mode: the UI is lying to you, politely.

Layer 3: my own script

The worst layer, because it was mine.

// roughly what it did
await clickPost();
console.log("posted");           // unconditional
postState[date] = { url: link }; // link was null
Enter fullscreen mode Exit fullscreen mode

Two bugs compounding:

  1. posted was printed whether or not the post existed — there was no verification step at all.
  2. When the resulting link was null (which it always was, because nothing was posted), the date was still written to the state file. Next run, that date is skipped as "already done".

So each silent failure became a permanent skip. Eight days of no posting became eight days of posted.

Failure mode: an optimistic state write that makes the failure sticky.

The fixes, in increasing order of usefulness

1. Guard before posting, not after.

const guard = {
  readOnly: /permanently in read-only|Your account is suspended/i.test(bodyText),
  btnDisabled: postButton?.disabled ?? true,
  composerReadOnly: composer?.getAttribute("contenteditable") !== "true",
};

if (guard.readOnly || guard.btnDisabled || guard.composerReadOnly) {
  log("FATAL: account cannot post", guard);
  process.exit(3);
}
Enter fullscreen mode Exit fullscreen mode

Exit 3 specifically, so the scheduler distinguishes "account is broken" from "network blip".

2. Verify after posting.

The only reliable signal is that the composer closed after the click. If the composer is still open three seconds later, nothing happened.

await clickPost();
await sleep(3000);
const stillOpen = await page.locator('[data-testid="tweetTextarea_0"]').count() > 0;
if (stillOpen) {
  log("FAIL: composer still open, post rejected");
  process.exit(2);
}
Enter fullscreen mode Exit fullscreen mode

3. Never write success state unless you have a URL.

if (!link) {
  log("FAIL: no post URL — refusing to mark as done");
  process.exit(3);
}
postState[date] = { url: link };
Enter fullscreen mode Exit fullscreen mode

That single rule would have caught this on day one.

What I'd tell anyone automating a social account

Don't trust posted. Trust evidence of a post: a permalink, or a verified DOM change. Everything else is a hope.

Treat the account as a dependency that can change underneath you. Browsers persist sessions; sessions get revoked, accounts get limited, cookies get replaced by another login in the same profile. I had a chrome-full profile whose identity drifted without me noticing.

Make the failure mode noisy. My mistake wasn't the missing verification — it was that every layer complained to a log nobody read. Infrastructure failure should page someone. Account failure should stop the schedule. Only the last one happened, and only after I looked.

Distinguish "nothing to do" from "could not do it". The script had one success path and no way to say "I refused." Exit codes are cheap and they carry more information than log lines.

The honest summary

Eight days, five posts, ~25 impressions, zero interactions.

So the automation's failure ended up mattering less than the strategy's failure. Even when it worked, ~3 impressions per post is not a distribution channel — it's a diary. Fixing the bot was the easy half.

I've stopped the calendar posting and moved to replying to people who are actually asking for help. More on whether that works in a few weeks.

(I build Speech Kobo, wedding speeches in four languages.)

Top comments (0)