Skip to content

Edge Function 'wall clock time limit reached'

“墙钟时间限制已到”是什么意思?

消息“挂钟时间限制已到”通常表示一个进程已经达到了允许的最大执行时间。这个时间是通过时钟来测量的,类似系统时钟或墙上的时钟。它包含了进程完成所需的整个时间,包括任何不活动或等待的时间。

🌐 The message "wall clock time limit reached" typically indicates that a process has reached the maximum time allowed for execution. This time is measured by a clock, similar to a system clock or a clock on the wall. It encompasses the entire duration a process takes to complete, including any periods of inactivity or waiting.

当这个消息出现在你的 edge 函数的上下文中时,这意味着该函数在达到指定的壁钟时间或达到资源限制(如 CPU 使用时间或内存使用量)后发出了关闭事件。

🌐 When this message appears in the context of your edge function, it means that the function has emitted a Shutdown event either after reaching the specified wall clock duration or when it hits a resource limit such as CPU time used or memory used.

当前限制说明

  • 挂钟时间限制:目前你的边缘函数总运行时间设置为 400 秒。
  • CPU 执行时间:限制为 200 毫秒的主动计算。

这意味着,如果你的边缘函数在这些时间限制内完成了任务,就不需要担心“达到实际时钟时间限制”的错误信息。

🌐 This means that if your edge function completes its task within these time constraints, there's no need to be concerned about the "wall clock time limit reached" error message.

因为在某些情况下可以预期会出现“挂钟时间限制已到”的警告。这个信息是硬编码的,当工作线程被终止时就会打印出来,即使它还没有达到时间限制。但是,如果你的函数在出现这个警告的情况下终止并返回 546 错误响应,这就说明你的函数超过了允许的执行时间,也就是有一个运行时间很长的任务。

🌐 Because the "wall clock time limit reached" warning can be expected in some cases. This message is hard-coded to be printed out when the worker has been terminated, even if it hasn't reached the time limit. However, if your function terminates with this warning and returns a 546 error response, then this indicates that your function is exceeding the allowed execution time, signaling a long-running task.

故障排除步骤 如果你遇到“已达到时钟时间限制”错误,错误代码为546,可以采取以下措施:

  • 检查你的函数逻辑:看看你的边缘函数里的操作有没有低效或者耗时的地方。考虑优化代码,减少不必要的计算,并在可能的情况下使用异步操作。
  • 拆分复杂任务:对于处理复杂或大规模任务的函数,试着将它们拆分成更小的独立函数。这种方法可以更有效地管理工作量,并保持在时间限制内。
  • 监控执行时间:使用我们提供的日志或监控工具来关注你的函数性能。这可以帮你找出需要优化的地方。要访问日志,请前往:Supabase 项目函数,选择你的函数并点击日志。
  • 查看我们的指南:想要更多技巧,请参考我们的调试指南:调试 Edge 函数

未来考虑 未来有计划让每个项目的挂钟时间限制可配置。不过,目前调整这个限制的唯一方法是自托管 Edge Functions

通过定期查看我们的更新日志 这里 来保持最新信息。

🌐 Stay updated on changes by regularly checking our changelog here.