{"slug":"workers-pitfalls-review","name":"Cloudflare Workers Review: D1, OpenNext, Fetch","version":"1.2.0","updated_at":"2026-10-09T07:17:23.453Z","use_when":"Reviews pasted Cloudflare Workers code and configuration (a Worker, a Next.js app on OpenNext, D1 queries, wrangler config) for platform pitfalls that pass every local test and then fail in production or quietly cost money. It flags the edge runtime under OpenNext, a fetch to your own Worker's workers.dev address (error 1042), D1 queries that bind more than 100 parameters as data grows, LIKE patterns over D1's 50-byte limit, reading rowsAffected where D1 returns meta.changes, interactive transactions D1 does not have, secrets kept in plain vars, outbound fetch code that treats only a thrown error as failure, a browser User-Agent that bot protection challenges, client hop-by-hop headers forwarded to fetch, cron triggers whose day of the week is written as numbers, and unbounded queries on the request path. Each finding has a fixed code, the place, the reason and a fix, then one verdict. Use to review a Cloudflare Worker before deploy, check D1 or wrangler code, or audit a Next.js app running on Cloudflare.","not_for":"General code review, style, performance tuning or security beyond the listed pitfalls, and anything that needs the running system: it reads pasted code, so it cannot see indexes, data sizes or bindings that the paste does not show, and it does not cover Durable Objects, Queues or KV.","languages":["any"],"tags":["cloudflare-workers","d1","opennext","code-review","deploy-check","wrangler"],"category":"code","category_url":"https://aiskills402.com/categories/code","keywords":["review a Cloudflare Worker","D1 or wrangler code","audit a Next.js app"],"faq":[{"q":"Which pitfalls does it look for?","a":"Twelve: the edge runtime under OpenNext, interactive D1 transactions, a cron weekday written as a number, a fetch to your own Worker's workers.dev address (error 1042), D1 queries past 100 bound parameters, LIKE patterns over 50 bytes, rowsAffected where D1 returns meta.changes, fetch code that only catches thrown errors, a browser User-Agent that bot protection challenges, forwarded hop-by-hop headers, secrets in plain vars and unbounded queries on the request path. Each was checked in the documentation or measured by us; the three fetch pitfalls of 1.1 were measured again on 8 October 2026."},{"q":"Does it help Claude Sonnet?","a":"A little, on measured facts. Without the skill Sonnet named sixteen of the nineteen planted pitfalls. It missed both browser User-Agent snippets (it called the header impolite or brittle, never that from a Worker it is what bot protection challenges) and a Sunday cron written as 0, which Cloudflare refuses at deploy. With the skill it named all nineteen. Haiku went from twelve to nineteen. The rest is the fixed codes and a verdict line a pipeline can act on."},{"q":"Will it flag code that is fine?","a":"Rarely, but not never. With version 1.1 Sonnet left all twelve correct snippets alone, including code that already uses a service binding or the global_fetch_strictly_public flag; Haiku flagged public vars holding a site address and a locale as secrets. A draft of 1.1 made Sonnet flag the fetch status on code that already checked it; that wording was fixed and the affected snippets were run again before release."},{"q":"Is calling my other Worker with fetch always a problem?","a":"No. We measured error 1042 only for the workers.dev address of a Worker on the same account; the other Worker's custom domain answered normally, even inside the same zone, so the skill leaves that alone. A service binding or the global_fetch_strictly_public compatibility flag removes the error, and the skill does not flag code that already uses either."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"// src/index.ts — a plain Worker, deployed with wrangler deploy\nexport default {\n  async fetch(): Promise<Response> {\n    return new Response(\"hello\");\n  },\n};","output_excerpt":"No findings.\nVerdict: no known pitfalls"}],"page_url":"https://aiskills402.com/skills/workers-pitfalls-review","markdown_url":"https://aiskills402.com/skills/workers-pitfalls-review.md","image_url":"https://cdn.aiskills402.com/og/skills/workers-pitfalls-review/c904ab98.png","related_url":"https://api.aiskills402.com/v1/skills/workers-pitfalls-review/related","purchases_count":null,"tested":{"date":"2026-10-08","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"Version 1.2, all thirty-three snippets: named every planted pitfall with the right code and verdict, including the new cron weekday one (a Sunday cleanup written as 0, which Cloudflare refuses at deploy, and a Monday-to-Friday report written as 1-5, which runs Sunday to Thursday), and left all fourteen correct snippets alone, among them a cron written with day names and one written 2-6 under a Monday-to-Friday comment."},"weak":{"model":"claude-haiku-5-5 (Claude Code alias \"haiku\")","verdict":"Named every planted pitfall in substance, but still slipped on the answer format four times with the skill: twice the verdict line was misplaced or left empty, once text followed the verdict, and once a correct hop-by-hop finding came without its code in brackets."},"note":"Thirty-three short snippets written by us: nineteen with one or two planted pitfalls and fourteen correct ones built to tempt a false alarm. The check requires each expected code and the verdict and forbids every code that should not appear; on two snippets where both readings are defensible an extra unbounded-query finding is allowed. The cron weekday pitfall added in 1.2 rests on our measurement of 8 October 2026 on Cloudflare (day 1 is Sunday; 0 is refused at deploy); the three outbound-fetch pitfalls of 1.1 were measured the same day with throwaway Workers. One run per model and case. The comparison without the skill covers only the nineteen snippets with a planted pitfall; false alarms are scored strictly, by code, on the side with the skill.","baseline":{"date":"2026-10-08","rows":[{"label":"Planted pitfalls named (19 snippets)","better":"higher","strong":{"with":{"n":19,"of":19},"without":{"n":16,"of":19}},"weak":{"with":{"n":19,"of":19},"without":{"n":12,"of":19}}}],"note":"One run per model and snippet, the same word-based check on both sides, every miss read by hand. Without the skill Sonnet missed three: both browser User-Agent snippets (it objected to the header on grounds of terms and brittleness, never that from a Worker it is what gets challenged) and the Sunday cron written as 0, which it did not know Cloudflare refuses; it did catch 1-5 as Sunday to Thursday. Haiku without the skill missed the same three, the 1-5 range, the edge runtime under OpenNext twice and D1's 50-byte LIKE limit. With the skill Haiku found all nineteen in substance; four of its answers broke the line format."},"report_url":null},"price_usd":"0.05","price_micro":50000,"size_bytes":9993,"sha256":"9161885db1e6dc83d9cb740b79ac667e2979623d307227431ff017807e604a65","outline":["The answer","The codes","Rules","Work in this order","Short example"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/workers-pitfalls-review/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0xbc0dcc70d8b5d85541d86ffc68d988fd59c22e68","facilitator":"cdp"},"seo_title":"Cloudflare Workers Pitfalls Review Skill (D1)","seo_description":"Reviews pasted Cloudflare Workers code for pitfalls like D1 parameter limits and error 1042 fetches, with a fix for each. $0.05 once, in USDC.","versions":[{"version":"1.2.0","date":"2026-10-08","changelog":"# Changelog\n\n## 1.2.0 — 2026-10-08\n\nNew: `[CRON-WEEKDAY]`, a wrangler cron trigger whose day-of-week field uses numbers. Cloudflare counts them from 1 = Sunday, so `1-5` runs Sunday to Thursday instead of Monday to Friday, and `0` (as in `0 3 * * 0` for every Sunday) is refused at deploy, which leaves the new code uploaded with the old schedule. The finding is in the group that breaks at once and names both effects; the fix is the day names (`MON-FRI`, `SUN`). A numeric range that really is Monday to Friday (`2-6`) is not flagged. Measured on 8 October 2026 with a throwaway Worker.\n\nPrice stays $0.05. Measured value for the strong model: Sonnet 16 of 19 planted pitfalls without the skill, 19 of 19 with it (the misses: both browser User-Agent snippets and the Sunday cron written as 0).\n\n## 1.1.0 — 2026-10-08\n\nThree platform facts measured again on the day with throwaway Workers. New: `[WORKERS-DEV-FETCH]`, a fetch to the workers.dev address of another Worker on the same account, which Cloudflare answers with 404 and error 1042 (fix: a service binding or the global_fetch_strictly_public flag; a custom domain is not flagged). New: `[BROWSER-UA]`, a browser User-Agent on outbound fetch, which bot protection challenges from a Worker while a bare request passes. `[HOP-BY-HOP]` now says what a forwarded `upgrade` does on the edge (the POST becomes a GET handshake without a body) and also catches filters that drop only part of the hop-by-hop set. Fetch codes apply only to code that runs in a Worker, and `[FETCH-STATUS]` now says that code which already checks the status, or a proxy that passes it on, is not a finding.\n\nPrice changed from $0.03 to $0.05. Measured value for the strong model: Sonnet 15 of 17 planted pitfalls without the skill, 17 of 17 with it (both misses were the browser User-Agent).\n\n## 1.0.0 — 2026-10-08\n\nFirst release: reviews pasted Cloudflare Workers code and configuration for platform pitfalls and lists each with a fixed code, the place, the reason and a fix, then a verdict (will break, fix before deploy, no known pitfalls). Breaks at once: the edge runtime under OpenNext, interactive D1 transactions. Breaks later or costs money: more than 100 bound D1 parameters, LIKE patterns over 50 bytes, rowsAffected instead of meta.changes, fetch code that only catches thrown errors, forwarded hop-by-hop headers, secrets in vars, unbounded queries on the request path.\n"},{"version":"1.1.0","date":"2026-10-08","changelog":"# Changelog\n\n## 1.1.0 — 2026-10-08\n\nThree platform facts measured again on the day with throwaway Workers. New: `[WORKERS-DEV-FETCH]`, a fetch to the workers.dev address of another Worker on the same account, which Cloudflare answers with 404 and error 1042 (fix: a service binding or the global_fetch_strictly_public flag; a custom domain is not flagged). New: `[BROWSER-UA]`, a browser User-Agent on outbound fetch, which bot protection challenges from a Worker while a bare request passes. `[HOP-BY-HOP]` now says what a forwarded `upgrade` does on the edge (the POST becomes a GET handshake without a body) and also catches filters that drop only part of the hop-by-hop set. Fetch codes apply only to code that runs in a Worker, and `[FETCH-STATUS]` now says that code which already checks the status, or a proxy that passes it on, is not a finding.\n\nPrice changed from $0.03 to $0.05. Measured value for the strong model: Sonnet 15 of 17 planted pitfalls without the skill, 17 of 17 with it (both misses were the browser User-Agent).\n\n## 1.0.0 — 2026-10-08\n\nFirst release: reviews pasted Cloudflare Workers code and configuration for platform pitfalls and lists each with a fixed code, the place, the reason and a fix, then a verdict (will break, fix before deploy, no known pitfalls). Breaks at once: the edge runtime under OpenNext, interactive D1 transactions. Breaks later or costs money: more than 100 bound D1 parameters, LIKE patterns over 50 bytes, rowsAffected instead of meta.changes, fetch code that only catches thrown errors, forwarded hop-by-hop headers, secrets in vars, unbounded queries on the request path.\n"},{"version":"1.0.0","date":"2026-10-08","changelog":"# Changelog\n\n## 1.0.0 — 2026-10-08\n\nFirst release: reviews pasted Cloudflare Workers code and configuration for platform pitfalls and lists each with a fixed code, the place, the reason and a fix, then a verdict (will break, fix before deploy, no known pitfalls). Breaks at once: the edge runtime under OpenNext, interactive D1 transactions. Breaks later or costs money: more than 100 bound D1 parameters, LIKE patterns over 50 bytes, rowsAffected instead of meta.changes, fetch code that only catches thrown errors, forwarded hop-by-hop headers, secrets in vars, unbounded queries on the request path.\n"}]}