Skip to content

fix: normalize Temporal objects to prevent native/polyfill mixing#99

Merged
ggaabe merged 1 commit intoggaabe:mainfrom
KristjanESPERANTO:fix/electron-40-native-temporal-compat
Jan 23, 2026
Merged

fix: normalize Temporal objects to prevent native/polyfill mixing#99
ggaabe merged 1 commit intoggaabe:mainfrom
KristjanESPERANTO:fix/electron-40-native-temporal-compat

Conversation

@KristjanESPERANTO
Copy link
Contributor

@KristjanESPERANTO KristjanESPERANTO commented Jan 22, 2026

The Problem

Starting with V8 14.4 (Electron 40, Chrome 134), JavaScript environments include native Temporal API support. Prior versions like V8 14.2 (Electron 39) do not have native Temporal.

When external libraries pass native Temporal objects to rrule-temporal, which internally uses the polyfill, operations like until() and compare() fail with errors:

TypeError: Temporal error: Must specify time zone.

This happens because the two Temporal implementations have different constructors, and methods like ZonedDateTime.until() reject objects from a different implementation.

In practice, this breaks applications using libraries like node-ical in Electron 40, where recurring calendar events fail to expand.

The Solution

Before calling until() or compare(), we now normalize all Temporal objects to the polyfill implementation by converting them through ISO strings:

const normalized = Temporal.ZonedDateTime.from(original.toString());

This ensures both operands use the same Temporal implementation, avoiding the type mismatch.

Testing

Added 7 regression tests covering the affected code paths in between().

Note: The tests use only polyfill objects and cannot reproduce the actual native/polyfill mixing scenario. The fix was validated in production environments with native Temporal API.

Mixing native Temporal API objects (V8 14.4+, Node 24+, Electron 40+)
with polyfill objects causes errors in until() and compare() operations.

Normalize all Temporal objects via toString()/from() before these calls
to ensure consistent implementation.

Added 7 regression tests (cannot reproduce mixing in test environment,
validated with Electron 40). All 890 tests pass.
@ggaabe ggaabe merged commit 8722840 into ggaabe:main Jan 23, 2026
1 check passed
@ggaabe
Copy link
Owner

ggaabe commented Jan 23, 2026

@KristjanESPERANTO rrule-temporal 2.0 will likely be a modified Bring-Your-Own-Temporal version where it doesn't include Temporal, and it accepts a Temporal interface where the developer passes in whichever Temporal they're using

@KristjanESPERANTO
Copy link
Contributor Author

Sounds good! And thanks for the merge 🙂

@KristjanESPERANTO KristjanESPERANTO deleted the fix/electron-40-native-temporal-compat branch January 23, 2026 20:04
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.

2 participants