-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathisolated.mjs
More file actions
39 lines (33 loc) · 715 Bytes
/
isolated.mjs
File metadata and controls
39 lines (33 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as Sentry from '@sentry/node';
import { longWork } from './long-work.js';
setTimeout(() => {
process.exit();
}, 10000);
function neverResolve() {
return new Promise(() => {
//
});
}
const fns = [
neverResolve,
neverResolve,
neverResolve,
neverResolve,
neverResolve,
longWork, // [5]
neverResolve,
neverResolve,
neverResolve,
neverResolve,
];
Sentry.getGlobalScope().setUser({ email: 'something@gmail.com' });
setTimeout(() => {
for (let id = 0; id < 10; id++) {
Sentry.withIsolationScope(async () => {
// eslint-disable-next-line no-console
console.log(`Starting task ${id}`);
Sentry.setUser({ id });
await fns[id]();
});
}
}, 1000);