Skip to content

Commit b993fce

Browse files
Merge branch 'develop' into manual-develop-sync
Co-Authored-By: Nicolas Hrubec <nico.hrubec@sentry.io>
2 parents c764ba8 + b264663 commit b993fce

26 files changed

Lines changed: 593 additions & 383 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
### Important Changes
8+
9+
- **ref(server-utils): Share one cron converter across cron integrations ([#25918](https://github.com/getsentry/sentry-javascript/pull/25918))**
10+
11+
`Sentry.cron.instrumentCron`, `instrumentNodeCron` and `instrumentNodeSchedule` send the server's time zone when a job has none, so monitors don't report false misses on servers that aren't on UTC. Schedules Sentry can't express exactly, such as per-second schedules, send no monitor config, so the monitor keeps the schedule set in Sentry. `Sentry.cron.instrumentNodeCron` is deprecated; use `nodeCronIntegration` instead.
12+
713
## 11.13.0
814

915
### Important Changes

‎dev-packages/e2e-tests/test-applications/nextjs-16-standalone/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@sentry/nextjs": "file:../../packed/sentry-nextjs-packed.tgz",
22-
"next": "16.3.3",
22+
"next": "16.4.5",
2323
"react": "19.1.0",
2424
"react-dom": "19.1.0"
2525
},

‎dev-packages/e2e-tests/test-applications/nextjs-16/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@vercel/queue": "^0.1.3",
4040
"ai": "^3.0.0",
4141
"ioredis": "5.10.1",
42-
"next": "16.4.2",
42+
"next": "16.4.5",
4343
"openai": "5.18.1",
4444
"pg": "^8.13.1",
4545
"react": "19.1.0",

‎dev-packages/e2e-tests/test-applications/vinext-cf-workers/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
1515
"@sentry/nextjs": "file:../../packed/sentry-nextjs-packed.tgz",
16-
"next": "16.4.1",
16+
"next": "16.4.5",
1717
"react": "^19.3.0",
1818
"react-dom": "^19.3.0"
1919
},

‎dev-packages/node-integration-tests/suites/cron/cron/scenario.ts‎

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,26 @@ const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'my-cron-job');
1010

1111
let closeNext = false;
1212

13-
const cron = new CronJobWithCheckIn('* * * * * *', () => {
14-
if (closeNext) {
15-
cron.stop();
16-
throw new Error('Error in cron job');
17-
}
18-
19-
// eslint-disable-next-line no-console
20-
console.log('You will see this message every second');
21-
closeNext = true;
22-
});
23-
24-
cron.start();
25-
26-
// `cron` sizes the delay to the next tick from two clock reads, clamps a negative result to -1 and
27-
// then treats that -1 as "stop". A pause between those two reads that straddles a second boundary
28-
// is enough to hit it, and the job is left scheduled for nothing: no ticks, no check-ins, and the
29-
// scenario exits on the timeout below having sent nothing at all. Starting again re-reads the clock
30-
// away from the boundary.
31-
for (let attempt = 0; attempt < 5 && !cron.isActive; attempt++) {
32-
cron.start();
33-
}
34-
35-
if (!cron.isActive) {
36-
throw new Error('`cron` refused to schedule the job');
37-
}
13+
const cron = new CronJobWithCheckIn(
14+
'0 9 * * 1-5',
15+
() => {
16+
if (closeNext) {
17+
throw new Error('Error in cron job');
18+
}
19+
20+
closeNext = true;
21+
},
22+
undefined,
23+
false,
24+
'Europe/Vienna',
25+
);
26+
27+
// Run the job without waiting for its schedule.
28+
(async () => {
29+
await cron.fireOnTick();
30+
await cron.fireOnTick();
31+
})();
3832

3933
setTimeout(() => {
4034
process.exit();
41-
}, 15_000);
35+
}, 10_000);

‎dev-packages/node-integration-tests/suites/cron/cron/test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { afterAll, expect, test } from 'vitest';
22
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
33

4+
const MONITOR_CONFIG = {
5+
schedule: { type: 'crontab', value: '0 9 * * 1-5' },
6+
timezone: 'Europe/Vienna',
7+
};
8+
49
afterAll(() => {
510
cleanupChildProcesses();
611
});
@@ -17,7 +22,7 @@ test('cron instrumentation', { timeout: 60_000 }, async () => {
1722
monitor_slug: 'my-cron-job',
1823
status: 'in_progress',
1924
release: '1.0',
20-
monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } },
25+
monitor_config: MONITOR_CONFIG,
2126
contexts: {
2227
trace: {
2328
trace_id: expect.stringMatching(/[a-f\d]{32}/),
@@ -47,7 +52,7 @@ test('cron instrumentation', { timeout: 60_000 }, async () => {
4752
monitor_slug: 'my-cron-job',
4853
status: 'in_progress',
4954
release: '1.0',
50-
monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } },
55+
monitor_config: MONITOR_CONFIG,
5156
contexts: {
5257
trace: {
5358
trace_id: expect.stringMatching(/[a-f\d]{32}/),

‎dev-packages/node-integration-tests/suites/cron/node-cron/base/scenario.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);
1313
let closeNext = false;
1414

1515
const task = cronWithCheckIn.schedule(
16-
'* * * * * *',
16+
'0 9 * * 1-5',
1717
() => {
1818
if (closeNext) {
19-
// https://github.com/node-cron/node-cron/issues/317
20-
setImmediate(() => {
21-
task.stop();
22-
});
23-
2419
throw new Error('Error in cron job');
2520
}
2621

27-
// eslint-disable-next-line no-console
28-
console.log('You will see this message every second');
2922
closeNext = true;
3023
},
31-
{ name: 'my-cron-job' },
24+
{ name: 'my-cron-job', timezone: 'Europe/Vienna' },
3225
);
3326

27+
// Run the task without waiting for its schedule.
28+
task.stop();
29+
task
30+
.execute()
31+
.then(() => task.execute())
32+
.catch(() => {});
33+
3434
setTimeout(() => {
3535
process.exit();
36-
}, 15_000);
36+
}, 10_000);

‎dev-packages/node-integration-tests/suites/cron/node-cron/base/test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { afterAll, expect, test } from 'vitest';
22
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
33

4+
const MONITOR_CONFIG = {
5+
schedule: { type: 'crontab', value: '0 9 * * 1-5' },
6+
timezone: 'Europe/Vienna',
7+
};
8+
49
afterAll(() => {
510
cleanupChildProcesses();
611
});
@@ -13,7 +18,7 @@ test('node-cron instrumentation', { timeout: 30_000 }, async () => {
1318
monitor_slug: 'my-cron-job',
1419
status: 'in_progress',
1520
release: '1.0',
16-
monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } },
21+
monitor_config: MONITOR_CONFIG,
1722
contexts: {
1823
trace: {
1924
trace_id: expect.stringMatching(/[a-f\d]{32}/),
@@ -43,7 +48,7 @@ test('node-cron instrumentation', { timeout: 30_000 }, async () => {
4348
monitor_slug: 'my-cron-job',
4449
status: 'in_progress',
4550
release: '1.0',
46-
monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } },
51+
monitor_config: MONITOR_CONFIG,
4752
contexts: {
4853
trace: {
4954
trace_id: expect.stringMatching(/[a-f\d]{32}/),

‎dev-packages/node-integration-tests/suites/cron/node-schedule/scenario.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);
1212

1313
let closeNext = false;
1414

15-
const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * * *', () => {
15+
const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '0 9 * * 1-5', () => {
1616
if (closeNext) {
17-
job.cancel();
1817
throw new Error('Error in cron job');
1918
}
2019

21-
// eslint-disable-next-line no-console
22-
console.log('You will see this message every second');
2320
closeNext = true;
2421
});
2522

23+
// Run the job without waiting for its schedule.
24+
job.cancel();
25+
// The second run's error is unhandled, like when node-schedule runs the job.
26+
void Promise.resolve(job.invoke()).then(() => job.invoke());
27+
2628
setTimeout(() => {
2729
process.exit();
28-
}, 15_000);
30+
}, 10_000);

‎dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { afterAll, expect, test } from 'vitest';
22
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
33

4+
const MONITOR_CONFIG = {
5+
schedule: { type: 'crontab', value: '0 9 * * 1-5' },
6+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
7+
};
8+
49
afterAll(() => {
510
cleanupChildProcesses();
611
});
@@ -13,7 +18,7 @@ test('node-schedule instrumentation', { timeout: 30_000 }, async () => {
1318
monitor_slug: 'my-cron-job',
1419
status: 'in_progress',
1520
release: '1.0',
16-
monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } },
21+
monitor_config: MONITOR_CONFIG,
1722
contexts: {
1823
trace: {
1924
trace_id: expect.stringMatching(/[a-f\d]{32}/),
@@ -43,7 +48,7 @@ test('node-schedule instrumentation', { timeout: 30_000 }, async () => {
4348
monitor_slug: 'my-cron-job',
4449
status: 'in_progress',
4550
release: '1.0',
46-
monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } },
51+
monitor_config: MONITOR_CONFIG,
4752
contexts: {
4853
trace: {
4954
trace_id: expect.stringMatching(/[a-f\d]{32}/),

0 commit comments

Comments
 (0)