Skip to content

Skip idle outbox cron so Neon can sleep - #23

Merged
cyx2007 merged 1 commit into
mainfrom
skip-idle-outbox-dispatch
Aug 23, 2026
Merged

Skip idle outbox cron so Neon can sleep#23
cyx2007 merged 1 commit into
mainfrom
skip-idle-outbox-dispatch

Conversation

@cyx2007

@cyx2007 cyx2007 commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Cloudflare 每分钟 outbox 调度在没有待投递事件时不再请求 Auth / 连接 Neon,避免计算一直醒着。
  • 写入 outbox 后通过 Worker POST /wake 设置 KV 标记;未绑定 KV 时保持旧的每次 dispatch,以免漏投递。
  • UTC 每 6 小时第 7 分钟仍强制巡检一次,兜底唤醒失败。

Test plan

  • pnpm validate(57 项通过)
  • 创建 KV OUTBOX_PENDING 并写入 wrangler binding
  • Vercel 配置 OUTBOX_WAKE_URL 为 Worker HTTPS /wake
  • 重新部署 Worker;空闲时 Neon 可休眠,改名/停账号后仍能在约 1 分钟内投递

Made with Cursor

Minute Cloudflare dispatch was querying Postgres even with an empty
outbox, which kept Neon compute awake. Wake the worker only after
enqueueing events, and skip Auth when the pending flag is absent.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cyx2007
cyx2007 requested a review from xiaoxuan010 as a code owner August 23, 2026 14:19
@cyx2007
cyx2007 merged commit fd47c96 into main Aug 23, 2026
3 checks passed
@cyx2007
cyx2007 deleted the skip-idle-outbox-dispatch branch August 23, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant