File tree Expand file tree Collapse file tree 6 files changed +74
-3
lines changed
dev-packages/node-integration-tests Expand file tree Collapse file tree 6 files changed +74
-3
lines changed Original file line number Diff line number Diff line change 36
36
"apollo-server" : " ^3.11.1" ,
37
37
"axios" : " ^0.27.2" ,
38
38
"cors" : " ^2.8.5" ,
39
+ "cron" : " ^3.1.6" ,
39
40
"express" : " ^4.17.3" ,
40
41
"graphql" : " ^16.3.0" ,
41
42
"http-terminator" : " ^3.2.0" ,
Original file line number Diff line number Diff line change
1
+ import * as Sentry from '@sentry/node' ;
2
+ import { CronJob } from 'cron' ;
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ const CronJobWithCheckIn = Sentry . cron . instrumentCron ( CronJob , 'my-cron-job' ) ;
6
+
7
+ setTimeout ( ( ) => {
8
+ process . exit ( 0 ) ;
9
+ } , 1_000 ) ;
Original file line number Diff line number Diff line change
1
+ import { cleanupChildProcesses , createRunner } from '../../../utils/runner' ;
2
+
3
+ afterAll ( ( ) => {
4
+ cleanupChildProcesses ( ) ;
5
+ } ) ;
6
+
7
+ test ( 'node-cron types should match' , done => {
8
+ createRunner ( __dirname , 'scenario.ts' ) . ensureNoErrorOutput ( ) . start ( done ) ;
9
+ } ) ;
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export function createRunner(...paths: string[]) {
70
70
const flags : string [ ] = [ ] ;
71
71
const ignored : EnvelopeItemType [ ] = [ ] ;
72
72
let withSentryServer = false ;
73
+ let ensureNoErrorOutput = false ;
73
74
74
75
if ( testPath . endsWith ( '.ts' ) ) {
75
76
flags . push ( '-r' , 'ts-node/register' ) ;
@@ -92,6 +93,10 @@ export function createRunner(...paths: string[]) {
92
93
ignored . push ( ...types ) ;
93
94
return this ;
94
95
} ,
96
+ ensureNoErrorOutput : function ( ) {
97
+ ensureNoErrorOutput = true ;
98
+ return this ;
99
+ } ,
95
100
start : function ( done ?: ( e ?: unknown ) => void ) {
96
101
const expectedEnvelopeCount = expectedEnvelopes . length ;
97
102
@@ -190,8 +195,19 @@ export function createRunner(...paths: string[]) {
190
195
191
196
CHILD_PROCESSES . add ( child ) ;
192
197
198
+ if ( ensureNoErrorOutput ) {
199
+ child . stderr . on ( 'data' , ( data : Buffer ) => {
200
+ const output = data . toString ( ) ;
201
+ complete ( new Error ( `Expected no error output but got: '${ output } '` ) ) ;
202
+ } ) ;
203
+ }
204
+
193
205
child . on ( 'close' , ( ) => {
194
206
hasExited = true ;
207
+
208
+ if ( ensureNoErrorOutput ) {
209
+ complete ( ) ;
210
+ }
195
211
} ) ;
196
212
197
213
// Pass error to done to end the test quickly
Original file line number Diff line number Diff line change @@ -8,10 +8,17 @@ export type CronJobParams = {
8
8
start ?: boolean | null ;
9
9
context ?: unknown ;
10
10
runOnInit ?: boolean | null ;
11
- utcOffset ?: number ;
12
- timeZone ?: string ;
13
11
unrefTimeout ?: boolean | null ;
14
- } ;
12
+ } & (
13
+ | {
14
+ timeZone ?: string | null ;
15
+ utcOffset ?: never ;
16
+ }
17
+ | {
18
+ timeZone ?: never ;
19
+ utcOffset ?: number | null ;
20
+ }
21
+ ) ;
15
22
16
23
export type CronJob = {
17
24
//
@@ -28,6 +35,17 @@ export type CronJobConstructor = {
28
35
timeZone ?: CronJobParams [ 'timeZone' ] ,
29
36
context ?: CronJobParams [ 'context' ] ,
30
37
runOnInit ?: CronJobParams [ 'runOnInit' ] ,
38
+ utcOffset ?: null ,
39
+ unrefTimeout ?: CronJobParams [ 'unrefTimeout' ] ,
40
+ ) : CronJob ;
41
+ new (
42
+ cronTime : CronJobParams [ 'cronTime' ] ,
43
+ onTick : CronJobParams [ 'onTick' ] ,
44
+ onComplete ?: CronJobParams [ 'onComplete' ] ,
45
+ start ?: CronJobParams [ 'start' ] ,
46
+ timeZone ?: null ,
47
+ context ?: CronJobParams [ 'context' ] ,
48
+ runOnInit ?: CronJobParams [ 'runOnInit' ] ,
31
49
utcOffset ?: CronJobParams [ 'utcOffset' ] ,
32
50
unrefTimeout ?: CronJobParams [ 'unrefTimeout' ] ,
33
51
) : CronJob ;
Original file line number Diff line number Diff line change 6268
6268
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03"
6269
6269
integrity sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w==
6270
6270
6271
+ "@types/luxon@~3.3.0":
6272
+ version "3.3.8"
6273
+ resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-3.3.8.tgz#84dbf2d020a9209a272058725e168f21d331a67e"
6274
+ integrity sha512-jYvz8UMLDgy3a5SkGJne8H7VA7zPV2Lwohjx0V8V31+SqAjNmurWMkk9cQhfvlcnXWudBpK9xPM1n4rljOcHYQ==
6275
+
6271
6276
6272
6277
version "2.1.33"
6273
6278
resolved "https://registry.yarnpkg.com/@types/md5/-/md5-2.1.33.tgz#8c8dba30df4ad0e92296424f08c4898dd808e8df"
11947
11952
postcss "^8.3.7"
11948
11953
pretty-bytes "^5.3.0"
11949
11954
11955
+ cron@^3.1.6:
11956
+ version "3.1.6"
11957
+ resolved "https://registry.yarnpkg.com/cron/-/cron-3.1.6.tgz#e7e1798a468e017c8d31459ecd7c2d088f97346c"
11958
+ integrity sha512-cvFiQCeVzsA+QPM6fhjBtlKGij7tLLISnTSvFxVdnFGLdz+ZdXN37kNe0i2gefmdD17XuZA6n2uPVwzl4FxW/w==
11959
+ dependencies:
11960
+ "@types/luxon" "~3.3.0"
11961
+ luxon "~3.4.0"
11962
+
11950
11963
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
11951
11964
version "6.0.5"
11952
11965
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
@@ -20696,6 +20709,11 @@ lunr@^2.3.8:
20696
20709
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
20697
20710
integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==
20698
20711
20712
+ luxon@~3.4.0:
20713
+ version "3.4.4"
20714
+ resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.4.4.tgz#cf20dc27dc532ba41a169c43fdcc0063601577af"
20715
+ integrity sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==
20716
+
20699
20717
lz-string@^1.4.4:
20700
20718
version "1.4.4"
20701
20719
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
You can’t perform that action at this time.
0 commit comments