Skip to content

Commit 71d7701

Browse files
committed
fix: remove duplicate AS enqueue from stale-flag reset path
When check_pending_site_created() detects a stale is_publishing flag, it was both enqueuing a new wu_async_publish_pending_site action AND returning publish_status=stopped to the frontend. This created two competing retry sources: the frontend polling loop (which retries on stopped, then reloads to kick cron) and the explicitly enqueued AS job. Both paths can trigger publish_pending_site() concurrently, risking a race condition where site creation is attempted twice simultaneously. Remove the wu_enqueue_async_action call. The frontend stopped response already handles retry (3 polls then page reload kicks cron), and the Action Scheduler will retry on the next cron run without an explicit enqueue. Fixes #793
1 parent 3d73e0f commit 71d7701

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

inc/managers/class-membership-manager.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,13 @@ public function check_pending_site_created() {
219219
);
220220

221221
/*
222-
* Re-enqueue the async action so Action Scheduler retries
223-
* the site creation without waiting for the next cron tick.
222+
* Return 'stopped' so the frontend retries via its own polling
223+
* loop. The Action Scheduler will also retry on the next cron
224+
* run. We do NOT enqueue an additional async action here because
225+
* that would create two competing retry sources — the frontend
226+
* poll and the AS job — which can race and attempt site creation
227+
* twice simultaneously.
224228
*/
225-
wu_enqueue_async_action('wu_async_publish_pending_site', ['membership_id' => $membership->get_id()], 'membership');
226-
227229
wp_send_json(['publish_status' => 'stopped']);
228230

229231
exit;

0 commit comments

Comments
 (0)