Menu

The Idempotency Bug That Spammed dev.to's API for Weeks
πŸ“°
0

The Idempotency Bug That Spammed dev.to's API for Weeks

DEV CommunityΒ·Anand RathnasΒ·about 1 month ago
#Fq8h3JLO
#how#javascript#api#sync#updatedat#frontmatter
Reading 0:00
15s threshold

This article was originally published on Jo4 Blog . We built a small tool to keep our dev.to posts in sync with our markdown source files. Write locally, push to Git, and the tool updates dev.to if anything changed. Simple. One morning, we noticed dev.to showing "Updated 2 hours ago" on an article we hadn't touched in weeks. Then we checked the logs. Every article with an updatedAt field in its frontmatter was being republished. Every. Single. Day. How the Sync Works The tool is straightforward: Read markdown posts with frontmatter ( title , publishAfter , updatedAt , etc.) For each post already on dev.to, check: "Has the local version changed since last sync?" If isUpdateNeeded() returns true , PUT the latest content to dev.to's API The check logic: function isUpdateNeeded ( localPost , devtoArticle ) { // If local content changed after dev.to publish date, update needed const localDate = localPost . updatedAt || localPost . publishAfter ; const devtoDate = devtoArticle .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More