Skip to content

fix(crontime): fall back to UTC when resolved timezone is invalid - #1075

Open
boluwatifeajayi wants to merge 1 commit into
kelektiv:mainfrom
boluwatifeajayi:fix/invalid-timezone-fallback
Open

fix(crontime): fall back to UTC when resolved timezone is invalid#1075
boluwatifeajayi wants to merge 1 commit into
kelektiv:mainfrom
boluwatifeajayi:fix/invalid-timezone-fallback

Conversation

@boluwatifeajayi

Copy link
Copy Markdown

Closes #1072

Problem

Intl.DateTimeFormat().resolvedOptions().timeZone can return "Etc/Unknown" on some Chromium-based browsers on Linux, which isn't a valid Luxon timezone — causing getNextDateFrom() to throw.

Fix

Validate the resolved timezone against Luxon (DateTime.fromObject({}, { zone: systemTimezone }).isValid) before assigning it. If invalid, log a warning (matching the existing style in job.ts) and leave timeZone unset, so the library falls back to UTC instead of throwing.

Testing

  • Added a test in crontime.test.ts stubbing Intl.DateTimeFormat to resolve "Etc/Unknown", asserting the fallback and warning fire and getNextDateFrom no longer throws
  • Full suite: 162/162 passing
  • Lint clean

Copilot AI review requested due to automatic review settings July 21, 2026 22:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens CronTime’s default timezone resolution to avoid exceptions when Intl.DateTimeFormat().resolvedOptions().timeZone returns a value Luxon considers invalid (e.g. "Etc/Unknown"), by validating before assignment and falling back to UTC behavior.

Changes:

  • Validate the resolved system timezone via Luxon before setting CronTime.timeZone; warn and avoid setting it when invalid.
  • Add a unit test intended to cover the invalid-system-timezone fallback behavior.
  • Update package-lock.json metadata (peer flag adjustments).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/time.ts Validate Intl-resolved timezone with Luxon and warn/fallback when invalid to prevent downstream scheduling failures.
tests/crontime.test.ts Adds a test for invalid resolved timezone; currently needs adjustment to exercise the fixed code path.
package-lock.json Lockfile metadata churn (peer field changes) accompanying the update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/crontime.test.ts
Intl.DateTimeFormat().resolvedOptions().timeZone can return the
invalid value "Etc/Unknown" on some Chromium-based browsers on
Linux. This caused getNextDateFrom() to throw when the invalid
timezone was passed to Luxon.

Now the resolved timezone is validated against Luxon before use.
If invalid, a warning is logged and CronTime falls back to UTC
instead of throwing.

Closes kelektiv#1072
@boluwatifeajayi
boluwatifeajayi force-pushed the fix/invalid-timezone-fallback branch from 82ef036 to 0264b54 Compare July 21, 2026 22:29
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.

.getNextDateFrom() fails when Intl resolves timezone to Etc/Unknown on Chromium-based Browser in Linux OS

2 participants