Use a named timezone as the default for unsafeMakeZoned
Type
- [ ] Refactor
- [ ] Feature
- [x] Bug Fix
- [ ] Optimization
- [ ] Documentation Update
Description
Okay, so this is timezone-related, so it's kind of confusing. I think the gist is: the root cause of is that when you do Cron.sequence with implicit timezones, you get into a situation in which,
- The cron occurs every week, and it hops from one Monday at 1pm to the next Monday at 1pm, and records that as the next tick
- But, daylight savings has happened so the cron should happen at 2pm instead of 1pm, so it jumps forward to 2pm and records that as the next tick
Which is how you get odd consecutive cron executions around time zones.
This PR makes 'implicit' timezones explicit internally using Intl.DateTimeFormat().resolvedOptions().timeZone. Is this good and the "right way to do it"? I'm not sure - this is pretty tricky stuff! But it does make crons consistent and a cron that should fire once a week does fire once a week reliably with this method.
Related
- Related Issue #
- Closes #5675
🦋 Changeset detected
Latest commit: fe42df87c342ab7bd371f6b3288c8036d2c1f231
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 36 packages
| Name | Type |
|---|---|
| effect | Patch |
| @effect/cli | Patch |
| @effect/cluster | Patch |
| @effect/experimental | Patch |
| @effect/opentelemetry | Patch |
| @effect/platform-browser | Patch |
| @effect/platform-bun | Patch |
| @effect/platform-node-shared | Patch |
| @effect/platform-node | Patch |
| @effect/platform | Patch |
| @effect/printer-ansi | Patch |
| @effect/printer | Patch |
| @effect/rpc | Patch |
| @effect/sql-clickhouse | Patch |
| @effect/sql-d1 | Patch |
| @effect/sql-drizzle | Patch |
| @effect/sql-kysely | Patch |
| @effect/sql-libsql | Patch |
| @effect/sql-mssql | Patch |
| @effect/sql-mysql2 | Patch |
| @effect/sql-pg | Patch |
| @effect/sql-sqlite-bun | Patch |
| @effect/sql-sqlite-do | Patch |
| @effect/sql-sqlite-node | Patch |
| @effect/sql-sqlite-react-native | Patch |
| @effect/sql-sqlite-wasm | Patch |
| @effect/sql | Patch |
| @effect/typeclass | Patch |
| @effect/vitest | Patch |
| @effect/workflow | Patch |
| @effect/ai | Patch |
| @effect/ai-amazon-bedrock | Patch |
| @effect/ai-anthropic | Patch |
| @effect/ai-google | Patch |
| @effect/ai-openai | Patch |
| @effect/ai-openrouter | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Hmm, having dug into it more I think the root cause might be that unsafeMakeZoned uses an offset-based timezone if one isn't given, and this doesn't compensate for timezone shifts correctly. I've updated this PR instead to improve that method to use the inferred named zone when one isn't given.
That said, I think that manually supplying an offset-based time zone to the Cron methods will still produce the original bug.