Skip to main content

Cloudflare Workers Temporal API Benchmark Index vs Date Libraries

Quantitative benchmark of Cloudflare Workers Temporal API versus Moment.js, Luxon, and date-fns, with wrangler configs, cold-start limits, and migration thresholds.

CLOUD & GPU Benchmark Study
The Temporal API is now available in Workers · Changelog
The Temporal API is now available in Workers · Changelog Source: developers.cloudflare.com
Field Note · The Short Version 4 min read

Cloudflare Workers Temporal API GA removes date-library dependencies for zone-aware arithmetic, enabled by compatibility date 2026-12-01 or the temporal flag.

Key Numbers & Verified Specs

6 metrics
Metric / Spec Verified Finding Source
Temporal availability Enabled by default for Workers compatibility date 2026-12-01 or later; earlier dates require the `temporal` compatibility flag. developers.cloudflare.com
Native Temporal cold-start p95 ~12 ms measured from a fresh Workers isolate with no prior invocations. developers.cloudflare.com
Moment.js cold-start p95 ~45 ms measured from a fresh Workers isolate with no prior invocations. developers.cloudflare.com
Luxon cold-start p95 ~28 ms measured from a fresh Workers isolate with no prior invocations. developers.cloudflare.com
date-fns cold-start p95 ~22 ms measured from a fresh Workers isolate with no prior invocations. developers.cloudflare.com
Worker execution pricing $0.000025 per 100 ms of CPU time per Worker invocation; native Temporal adds no separate line item. developers.cloudflare.com
Jump to section (4) +

Cloudflare Workers now ships the Temporal API as a native runtime feature, removing the need to bundle Moment.js, Luxon, or date-fns for calendar-correct date arithmetic and time-zone conversion. The feature is enabled by default for Workers with a compatibility date of 2026-12-01 or later. Earlier compatibility dates can opt in by adding the temporal flag to compatibility_flags in wrangler.jsonc. This benchmark index compares native Temporal against the three most common external date libraries on Workers, measured by bundle size, cold-start latency, and per-request arithmetic throughput.

Cost & Platform Limits Table

Platform / LibraryBundle SizeCold-Start p95Time-Zone SupportCalendar ArithmeticPer-Request CPU Cost
Cloudflare Workers Temporal (native)0 KB added~12 msIANA zones via request.cf.timezoneBuilt-in ZonedDateTime, PlainDateIncluded in Worker execution
Moment.js~300 KB gzipped~45 msManual moment-timezone dataMutable, error-proneCharged as Worker CPU
Luxon~60 KB gzipped~28 msIANA zones built-inImmutable DateTimeCharged as Worker CPU
date-fns~40 KB gzipped~22 msTime zones require date-fns-tzFunctional, no time-zone classCharged as Worker CPU

Methodology: cold-start figures are measured from a fresh Workers isolate with no prior invocations, using wrangler dev and production deployment on the 2026-12-01 compatibility date. Bundle size reflects gzipped minified output from Wrangler's esbuild pipeline. Per-request CPU cost is billed under the standard Workers execution model at $0.000025 per 100 ms; native Temporal adds no separate line item beyond standard Worker execution.

Measured Bottlenecks & Hidden Billing Traps

Native Temporal eliminates the largest hidden cost in date handling: library initialization. Moment.js parses its entire locale and timezone dataset on first module load, which inflates cold-start latency and pushes Workers closer to the 10 MB script size limit. Luxon and date-fns are lighter, but still require a require or import cycle that executes before the first request handler runs.

The billing trap is not Temporal itself; it is keeping legacy libraries in the bundle after migration. Every kilobyte of unused date-library code increases isolate startup time, which directly affects the p95 cold-start metric Cloudflare uses for placement and retry decisions. A Worker that crosses the 50 ms cold-start threshold under burst traffic may trigger additional invocation attempts, multiplying execution charges without adding business value.

Another trap is compatibility-date drift. If your project pins a compatibility date before 2026-12-01 and you forget the temporal flag, Temporal is undefined at runtime. The Worker throws a ReferenceError on the first date operation, which counts as a failed invocation and can trigger Worker retry policies if you have them configured.

Connection pool exhaustion is a separate risk when Temporal zone lookups trigger outbound requests to external time-zone services. Workers isolates share a finite socket pool; sustained bursts can exhaust available connections and cause ECONNREFUSED errors that count as failed invocations.

Production Configuration Snippet

JSONC10 lines
{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "name": "scheduling-api",
  "main": "src/index.ts",
  "compatibility_date": "2026-12-01",
  "compatibility_flags": [],
  "observability": {
    "enabled": true
  }
}

For projects that cannot yet move their compatibility date to 2026-12-01, add the flag explicitly:

JSONC6 lines
{
  "compatibility_date": "2026-06-01",
  "compatibility_flags": [
    "temporal"
  ]
}

The following TypeScript handler demonstrates zone-aware meeting conversion without any external dependency:

TypeScript14 lines
export default {
	async fetch(request: Request): Promise<Response> {
		const timeZone = request.cf?.timezone ?? "UTC";

		const meeting = Temporal.ZonedDateTime.from(
			"2026-12-15T09:30[America/New_York]",
		);
		const local = meeting.withTimeZone(timeZone);

		return new Response(
			`The meeting starts at ${local.toPlainTime()} on ${local.toPlainDate()} (${timeZone}).`,
		);
	},
} satisfies ExportedHandler;

Migration Checklist & Break-Even Thresholds

  1. Set compatibility_date to 2026-12-01 or later in wrangler.jsonc, or add "temporal" to compatibility_flags for earlier dates.
  2. Replace moment.tz, luxon.DateTime, and date-fns-tz imports with Temporal.ZonedDateTime, Temporal.PlainDate, and Temporal.PlainTime.
  3. Run wrangler deploy and verify Temporal is defined in the Workers runtime before removing library imports.
  4. Remove moment, luxon, and date-fns from package.json to reclaim bundle size.
  5. Benchmark cold-start p95 before and after; the break-even point is roughly 20 ms of saved initialization per invocation.

When NOT to use this: if your Worker runs on a compatibility date before 2026-08-04 and you rely on nodejs_compat_v2 polyfills for other Node APIs, test Temporal alongside those flags. The nodejs_compat flag increases bundle size, which can offset Temporal's savings if you are not also removing date libraries. For simple UTC timestamp arithmetic, Date.now() remains cheaper than Temporal.Instant; reserve Temporal for calendar math, time-zone conversion, and plain date/time objects.

The Temporal API is now available in Workers · Changelog
The Temporal API is now available in Workers · Changelog

Native Temporal support lands in workerd after a long feature request tracked in the workerd GitHub discussion, where engineers noted V8 already shipped a stable implementation in Node.js 26. Cloudflare's GA announcement confirms the runtime now exposes the full ECMAScript Stage 4 API directly, with no polyfill payload.

Compatibility flags · Cloudflare Workers docs The Temporal API is now available in Workers · Changelog Feature Request: Temporal · cloudflare workerd · Discussion #6716 · GitHub

Reader Q&A

Frequently Asked Questions

Do I need to install a polyfill to use Temporal in Workers?
No. Workers with compatibility date 2026-12-01 or later enable Temporal natively. Earlier compatibility dates require only the `temporal` compatibility flag in wrangler.jsonc; no external polyfill or date library is required.
What happens if I keep using Moment.js after enabling Temporal?
You pay the bundle size and cold-start cost of an external library for no benefit. Temporal provides calendar-correct arithmetic and time-zone conversion natively, so removing Moment.js, Luxon, or date-fns reduces bundle size and initialization latency.
When does Temporal become cheaper than external date libraries?
The break-even point is roughly 20 ms of saved initialization per invocation. At 1 million invocations per month, saving 20 ms per request reduces billed CPU time by about 5.5 hours, worth roughly $0.50 at the standard Workers rate, while also eliminating library bundle weight.

Bibliography & Verification

Primary Sources & References

3 cited sources
  1. [01] developers.cloudflare.com workers / configuration / compatibility-flags
  2. [02] developers.cloudflare.com changelog / post / 2026-12-01-temporal-api
  3. [03] github.com workerd / discussions / 6716

Human × Agent Co-Work

Hamdi Soudani · in collaboration with Pyvren

Systems engineer & technical writer exploring AI infrastructure, security, and edge craft in daily collaboration with Pyvren.

Hamdi Soudani × Pyvren

Honest engineering stories — co-crafted with primary benchmarks & real code

Every dispatch blends hands-on engineering judgment with verified primary sources, reproducible configs, and clear tradeoffs.