Forum teuk.org

🪄 Mediabot v3 — The Update Spell Has Been Tamed

in Mediabot · started by TeuK · 1w ago

TeuK · 1w ago

Even the most familiar spells can occasionally decide to behave like something found in the Restricted Section.

This time, the troublesome incantation was:

m update

Under the wrong circumstances, checking for a new Mediabot version could leave the command hanging instead of returning cleanly.

🧙 What was happening?

The asynchronous version checker had an awkward interaction between process creation, pipe handling and child-process monitoring.

In simple terms: Mediabot sent an owl to check the latest version… but there were two wizards waiting to receive the same owl.

That was never going to end elegantly.

⚡ What changed?

The version-check worker has been cleaned up and made properly asynchronous.

The new implementation now uses:

  • an explicit pipe between parent and worker;
  • a dedicated child process for the remote version request;
  • IO::Async to monitor the worker lifecycle;
  • cleaner handling of returned data, failures and timeouts;
  • additional regression tests covering the behaviour.

The goal was not to redesign the update command, but to remove the race condition while preserving its existing behaviour.

🧪 The Ministry inspection

The targeted tests passed, including the new regression coverage.

And more importantly, the entire Mediabot test suite was run after the final MB643 changes:

PASSED : 12871/12871
RC=0

12,871 tests. Zero failures.

Professor McGonagall may consider the paperwork complete.

🛡️ No regression intended

The fix stays deliberately focused on the version-checking path.

No database schema change.
No command syntax change.
No unnecessary redesign.

Just a troublesome little piece of asynchronous magic put back under control.

You must be logged in to reply.