-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathisolated.mjs
51 lines (42 loc) · 990 Bytes
/
isolated.mjs
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
40
41
42
43
44
45
46
47
48
49
50
51
import * as assert from 'assert';
import * as crypto from 'crypto';
import * as Sentry from '@sentry/node';
setTimeout(() => {
process.exit();
}, 10000);
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});
async function longWork() {
await new Promise(resolve => setTimeout(resolve, 1000));
for (let i = 0; i < 20; i++) {
const salt = crypto.randomBytes(128).toString('base64');
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512');
assert.ok(hash);
}
}
function neverResolve() {
return new Promise(() => {
//
});
}
const fns = [
neverResolve,
neverResolve,
neverResolve,
neverResolve,
neverResolve,
longWork, // [5]
neverResolve,
neverResolve,
neverResolve,
neverResolve,
];
for (let id = 0; id < 10; id++) {
Sentry.withIsolationScope(async () => {
Sentry.setUser({ id });
await fns[id]();
});
}