Script exceeded CPU time limit error with crypto.subtle and compatibility_date
0 reputation · 22 Oct 2023, 00:25 UTC
Cloudflare Workers enforce a per-request CPU time limit on the free tier, and the execution duration of the crypto.subtle API varies with the worker's compatibility_date setting. With a compatibility_date prior to 2023-09-01 the runtime uses an older isolate where certain cryptographic operations can exceed the limit and produce the Script exceeded CPU time limit error. With compatibility_date set to 2023-09-01 or later the runtime enables a newer V8 isolate with an optimized Web Crypto implementation that reduces the likelihood of limit breaches for equivalent workloads.
The transition is not uniform. Libraries that rely on older Node.js crypto polyfills may still experience intermittent limit breaches even with the newer compatibility date, indicating an unresolved tension between backward compatibility and predictable performance. Local development with wrangler dev does not always mirror production CPU limit behavior, leaving the practical impact of compatibility_date choices uncertain for reproducible builds.
Which compatibility_date values produce consistent CPU limit compliance for crypto.subtle-based workloads in production? How does the choice interact with third-party crypto polyfills under the newer isolate? What observable behavior differences remain between pre-2023-09-01 and 2023-09-01+ runtimes for the same crypto.subtle operations?