fix(crontime): fall back to UTC when resolved timezone is invalid - #1075
Open
boluwatifeajayi wants to merge 1 commit into
Open
fix(crontime): fall back to UTC when resolved timezone is invalid#1075boluwatifeajayi wants to merge 1 commit into
boluwatifeajayi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.jsonmetadata (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.
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
force-pushed
the
fix/invalid-timezone-fallback
branch
from
July 21, 2026 22:29
82ef036 to
0264b54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1072
Problem
Intl.DateTimeFormat().resolvedOptions().timeZonecan return "Etc/Unknown" on some Chromium-based browsers on Linux, which isn't a valid Luxon timezone — causinggetNextDateFrom()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 leavetimeZoneunset, so the library falls back to UTC instead of throwing.Testing