Edge Function error: 'Rate limit exceeded for trace'
Last edited: 8/12/2026
如果你在调用 Edge Functions 时遇到 RateLimitError: "Rate limit exceeded for trace ..." 错误,这通常意味着单次函数执行同时触发了太多下游调用。
🌐 If you are observing a RateLimitError: "Rate limit exceeded for trace ..." error when invoking Edge Functions, it typically indicates that a single function execution is triggering too many downstream calls simultaneously.
这是为什么会发生?
- 这种情况经常发生在“扇出”场景中,比如一个由 cron 驱动的函数循环调用其他函数的时候。
- 从同一个父执行发起的所有下游
supabase.functions.invoke()调用共享一个 Trace ID。这些调用使用的是特定的每条 trace 的安全预算,而不是整个项目级别的总容量。如果调用量太大,预算就会用尽,后续的调用会被限制。
如何解决这个问题:
- 调用速度调整: 在生产者函数中,在每次
invoke()调用之间引入延迟(例如,几百毫秒),以保持在跟踪预算内。 - 批量负载: 重构下游函数以接受数据数组,这样一次调用就能处理多条记录,而不是为每条记录单独触发调用。
- **整合逻辑:**把逻辑重构到一个共享库里,或者直接放到调用函数里,这样就不用跨函数做网络调用了。
你可以通过访问 日志浏览器 来监控这些错误,以找出哪些执行超出了它们的跟踪预算。
🌐 You can monitor these errors by visiting the logs explorer to identify which executions are exceeding their trace budget.
想了解递归调用和每条跟踪速率限制的工作原理,看看递归函数指南:递归函数——什么会受到速率限制
🌐 For more details on how recursive invocations and per-trace rate limiting work, see the recursive functions guide: Recursive Functions — What gets rate limited.