Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): Time zone handling for cron #11225

Merged
merged 1 commit into from Mar 21, 2024

Conversation

joshkel
Copy link
Contributor

@joshkel joshkel commented Mar 21, 2024

The cron package uses timeZone, while Sentry internally uses timezone. This caused Sentry cron jobs to be incorrectly upserted with no time zone information. Because of the use of the ...(timeZone ? { timeZone } : undefined) idiom, TypeScript type checking did not catch the mistake.

I kept cron's timeZone capitalization within Sentry's instrumentation and changed from the ...(timeZone ? { timeZone } : undefined) idiom so TypeScript could catch mistakes of this sort. (Passing an undefined timezone appears to be okay, because Sentry's node-cron instrumentation does it.)

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

The `cron` package uses `timeZone`, while Sentry internally uses `timezone`. This caused Sentry cron jobs to be incorrectly upserted with no time zone information. Because of the use of the `...(timeZone ? { timeZone } : undefined)` idiom, TypeScript type checking did not catch the mistake.

I kept `cron`'s `timeZone` capitalization within Sentry's instrumentation and changed from the `...(timeZone ? { timeZone } : undefined)` idiom so TypeScript could catch mistakes of this sort. (Passing an undefined `timezone` appears to be okay, because Sentry's `node-cron` instrumentation does it.)
Copy link
Collaborator

@timfish timfish left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for fixing this!

@AbhiPrasad AbhiPrasad merged commit e9c1845 into getsentry:develop Mar 21, 2024
51 checks passed
@AbhiPrasad
Copy link
Member

Will backport this for v7 - release will come out soon!

@joshkel joshkel deleted the cron-timezone branch March 21, 2024 15:57
AbhiPrasad pushed a commit that referenced this pull request Mar 21, 2024
The `cron` package uses `timeZone`, while Sentry internally uses
`timezone`. This caused Sentry cron jobs to be incorrectly upserted with
no time zone information. Because of the use of the `...(timeZone ? {
timeZone } : undefined)` idiom, TypeScript type checking did not catch
the mistake.

I kept `cron`'s `timeZone` capitalization within Sentry's
instrumentation and changed from the `...(timeZone ? { timeZone } :
undefined)` idiom so TypeScript could catch mistakes of this sort.
(Passing an undefined `timezone` appears to be okay, because Sentry's
`node-cron` instrumentation does it.)
@AbhiPrasad
Copy link
Member

cadesalaberry pushed a commit to cadesalaberry/sentry-javascript that referenced this pull request Apr 19, 2024
The `cron` package uses `timeZone`, while Sentry internally uses
`timezone`. This caused Sentry cron jobs to be incorrectly upserted with
no time zone information. Because of the use of the `...(timeZone ? {
timeZone } : undefined)` idiom, TypeScript type checking did not catch
the mistake.

I kept `cron`'s `timeZone` capitalization within Sentry's
instrumentation and changed from the `...(timeZone ? { timeZone } :
undefined)` idiom so TypeScript could catch mistakes of this sort.
(Passing an undefined `timezone` appears to be okay, because Sentry's
`node-cron` instrumentation does it.)
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.

None yet

4 participants