Repository navigation
Closed
Labels
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
7.94.1
Framework Version
No response
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
I try the example given at
https://docs.sentry.io/platforms/node/crons/#cron
For my project in typescript. Using the latest versions of both cron and @sentry/node
import * as Sentry from "@sentry/node";
import { CronJob } from "cron";
const CronJobWithCheckIn = Sentry.cron.instrumentCron(
CronJob,
"my-cron-job"
);However I get a Type error as the type expected by instrumentCron does not match the actual one from CronJob:
error TS2345: Argument of type 'typeof CronJob' is not assignable to parameter of type 'typeof CronJob & CronJobConstructor'.
Type 'typeof CronJob' is not assignable to type 'CronJobConstructor'.
Types of property 'from' are incompatible.
Type '<OC extends CronOnCompleteCommand | null = null, C = null>(params: CronJobParams<OC, C>) => CronJob<OC, C>' is not assignable to type '(param: CronJobParams) => CronJob'.
Types of parameters 'params' and 'param' are incompatible.
Type 'CronJobParams' is not assignable to type 'CronJobParams<() => void | Promise<void>, unknown>'.
Type 'CronJobParams' is not assignable to type 'BaseCronJobParams<() => void | Promise<void>, unknown> & { timeZone?: undefined; utcOffset?: number | null | undefined; }'.
Type 'CronJobParams' is not assignable to type '{ timeZone?: undefined; utcOffset?: number | null | undefined; }'.
Types of property 'timeZone' are incompatible.
Type 'string | undefined' is not assignable to type 'undefined'.
Type 'string' is not assignable to type 'undefined'.
From the error description it seems CronJobConstructor.from is not correctly defined.
Expected Result
Example from the documentation should be working.
Actual Result
Does not work :(
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
Lms24 commentedon Jan 23, 2024
Hi @Tethik thanks for writing in!
Gonna tag @timfish - please take a look at this when you have a minute, thank you!
Tethik commentedon Jan 23, 2024
cronlibs definitionhttps://github.com/kelektiv/node-cron/blob/94e8aace1a797fde0b1e83b20e4918f14bb36582/src/types/cron.types.ts#L20-L33
vs sentry:
sentry-javascript/packages/node/src/cron/cron.ts
Lines 4 to 14 in 62b0c4d
Tethik commentedon Jan 23, 2024
Likely the issue is that
utcOffsetcan never beneverwith the way it's translated.timfish commentedon Jan 24, 2024
Thanks for the details. I'm going to add a TypeScript integration test so this is tested in the future.