Count Publication Attempts Without Double-Counting Retries
Learn how to measure consecutive scheduled publications using durable attempt ownership, immutable article identity, and version-bound streaks.
Table of Contents6 sections

A scheduled content pipeline can finish successfully as a process without delivering an article, while retries and late deployment checks can credit the same article twice.
Quick solution: Use a version-bound attempt counter that verifies live publication before incrementing streaks, as shown in this minimal configuration for Cloudflare Workflows Workers API.
export class PublicationWorkflow extends WorkflowEntrypoint {
async run(event: WorkflowEvent, step: WorkflowStep) {
const articleId = event.payload.articleId;
const codeVersion = event.payload.codeVersion;
const isLive = await step.do('verify-live-proof', async () => {
return await checkLiveEndpoint(articleId);
});
if (!isLive) {
return { status: 'blocked', reason: 'live check failed' };
}
await step.do('increment-streak', async () => {
return await updateDbStreak(codeVersion, articleId);
});
}
}
Why Workflow Completion Differs From Article Publication
A workflow runtime environment can finish its execution block successfully without the external target system acknowledging the artifact. Infrastructure timeouts, DNS propagation delays, or downstream storage rejections can cause a process to exit with a success code while leaving the public endpoint empty. Treating process exit status as definitive publication leads to phantom metrics and inflated success rates. Production stability has not yet been established for local dry-runs, so pipelines require separate validation gates.
Preventing Duplicate Credit After a Crash
When a worker crashes immediately after publishing an article but before recording the state locally, automatic retry mechanisms trigger a second execution. Without idempotency guards, the second run treats the article as new and increments credit counters twice. To prevent this, pipelines must assign an immutable article identity before dispatching the payload. When checking status, the system queries the target storage for the unique identifier rather than relying on internal execution logs. If the artifact exists, the retry records a duplicate attempt without altering the primary credit count.
Why Changing Code Resets a Verification Streak
Modifying the underlying pipeline code changes the execution characteristics and invalidates historical verification assumptions. A streak measures consecutive successful runs under a specific operational contract. When code changes, previous success metrics no longer guarantee that the new logic behaves identically under failure conditions. Tying streaks to code versions prevents silent regressions from inheriting past reliability credit. If you manage deployments using Controlled Cloudflare Pages Deployments, version bounds ensure that logic updates cleanly isolate verification history.
How a Blocked Writer Retains Ownership
When an article encounters a publishing block or an ambiguous deployment state, ownership must remain assigned to the original writer context until verification completes. Releasing ownership prematurely during a timeout or network partition allows competing processes to claim stale tasks, resulting in conflicting writes. The orchestration layer must maintain a locked state window during which manual recovery or automated retries can query the exact provenance of the article without triggering race conditions.
Verification and Execution Checklist
- Confirm that workflow completion events check external storage before updating local counters.
- Verify that unique article identifiers persist across retry boundaries.
- Ensure code version updates trigger a clean reset in streak evaluation tables.
- Test failure modes where network partitions interrupt the final write step.
Continue Exploring
You Might Also Like

Design Publishing Queues That Survive Image Provider Outages
Separate content validity from media-provider availability so transient image failures defer the same article instead of discarding work or creating duplicates.

Rebase Git Publication Finalization
Learn how to safely finish Git-backed publication finalizations during concurrent vault syncs by rebasing lifecycle updates over unrelated changes.

Obsidian Plugin Error Logging Without Telemetry
Build a local-first error log with bounded retention, secret redaction, and user-initiated reporting for plugin ecosystems that prohibit client telemetry.