Skip to content

Commit 1421014

Browse files
committed
Mostly workintg
1 parent b5b0027 commit 1421014

34 files changed

+845
-888
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as Sentry from '@sentry/node';
2+
import { threadBlockedIntegration } from '@sentry/node-native';
3+
import * as path from 'path';
4+
import * as url from 'url';
5+
import { longWork } from './long-work.js';
6+
7+
global._sentryDebugIds = { [new Error().stack]: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' };
8+
9+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
10+
11+
setTimeout(() => {
12+
process.exit();
13+
}, 10000);
14+
15+
Sentry.init({
16+
dsn: process.env.SENTRY_DSN,
17+
release: '1.0',
18+
integrations: [threadBlockedIntegration({ blockedThreshold: 100, appRootPath: __dirname })],
19+
});
20+
21+
setTimeout(() => {
22+
longWork();
23+
}, 1000);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as Sentry from '@sentry/node';
2+
import { threadBlockedIntegration } from '@sentry/node-native';
3+
import { longWork } from './long-work.js';
4+
5+
global._sentryDebugIds = { [new Error().stack]: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' };
6+
7+
setTimeout(() => {
8+
process.exit();
9+
}, 10000);
10+
11+
Sentry.init({
12+
dsn: process.env.SENTRY_DSN,
13+
release: '1.0',
14+
integrations: [threadBlockedIntegration({ blockedThreshold: 100, maxBlockedEvents: 2 })],
15+
});
16+
17+
setTimeout(() => {
18+
longWork();
19+
}, 1000);
20+
21+
setTimeout(() => {
22+
longWork();
23+
}, 4000);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const Sentry = require('@sentry/node');
2+
const { threadBlockedIntegration } = require('@sentry/node-native');
3+
const { longWork } = require('./long-work.js');
4+
5+
global._sentryDebugIds = { [new Error().stack]: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' };
6+
7+
setTimeout(() => {
8+
process.exit();
9+
}, 10000);
10+
11+
Sentry.init({
12+
dsn: process.env.SENTRY_DSN,
13+
release: '1.0',
14+
integrations: [threadBlockedIntegration({ blockedThreshold: 100 })],
15+
});
16+
17+
setTimeout(() => {
18+
longWork();
19+
}, 2000);
20+
21+
// Ensure we only send one event even with multiple blocking events
22+
setTimeout(() => {
23+
longWork();
24+
}, 5000);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as Sentry from '@sentry/node';
2+
import { threadBlockedIntegration } from '@sentry/node-native';
3+
import { longWork } from './long-work.js';
4+
5+
global._sentryDebugIds = { [new Error().stack]: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' };
6+
7+
setTimeout(() => {
8+
process.exit();
9+
}, 12000);
10+
11+
Sentry.init({
12+
dsn: process.env.SENTRY_DSN,
13+
release: '1.0',
14+
integrations: [threadBlockedIntegration({ blockedThreshold: 100 })],
15+
});
16+
17+
setTimeout(() => {
18+
longWork();
19+
}, 2000);
20+
21+
// Ensure we only send one event even with multiple blocking events
22+
setTimeout(() => {
23+
longWork();
24+
}, 5000);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as Sentry from '@sentry/node';
2+
import { threadBlockedIntegration } from '@sentry/node-native';
3+
import * as assert from 'assert';
4+
import * as crypto from 'crypto';
5+
6+
setTimeout(() => {
7+
process.exit();
8+
}, 10000);
9+
10+
Sentry.init({
11+
dsn: process.env.SENTRY_DSN,
12+
release: '1.0',
13+
integrations: [threadBlockedIntegration({ blockedThreshold: 100 })],
14+
});
15+
16+
function longWork() {
17+
// This loop will run almost indefinitely
18+
for (let i = 0; i < 2000000000; i++) {
19+
const salt = crypto.randomBytes(128).toString('base64');
20+
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512');
21+
assert.ok(hash);
22+
}
23+
}
24+
25+
setTimeout(() => {
26+
longWork();
27+
}, 1000);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/node';
2+
import { threadBlockedIntegration } from '@sentry/node-native';
3+
4+
Sentry.init({
5+
debug: true,
6+
dsn: process.env.SENTRY_DSN,
7+
release: '1.0',
8+
integrations: [threadBlockedIntegration({ blockedThreshold: 100 })],
9+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const crypto = require('crypto');
2+
const assert = require('assert');
3+
4+
function longWork() {
5+
for (let i = 0; i < 20; i++) {
6+
const salt = crypto.randomBytes(128).toString('base64');
7+
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512');
8+
assert.ok(hash);
9+
}
10+
}
11+
12+
exports.longWork = longWork;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Sentry = require('@sentry/node');
2+
const { threadBlockedIntegration } = require('@sentry/node-native');
3+
4+
function configureSentry() {
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0',
8+
debug: true,
9+
integrations: [threadBlockedIntegration()],
10+
});
11+
}
12+
13+
async function main() {
14+
configureSentry();
15+
await new Promise(resolve => setTimeout(resolve, 1000));
16+
process.exit(0);
17+
}
18+
19+
main();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Sentry = require('@sentry/node');
2+
const { threadBlockedIntegration } = require('@sentry/node-native');
3+
4+
function configureSentry() {
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0',
8+
debug: true,
9+
integrations: [threadBlockedIntegration()],
10+
});
11+
}
12+
13+
async function main() {
14+
configureSentry();
15+
await new Promise(resolve => setTimeout(resolve, 1000));
16+
}
17+
18+
main();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const Sentry = require('@sentry/node');
2+
const { threadBlockedIntegration } = require('@sentry/node-native');
3+
const { longWork } = require('./long-work.js');
4+
const crypto = require('crypto');
5+
const assert = require('assert');
6+
7+
setTimeout(() => {
8+
process.exit();
9+
}, 10000);
10+
11+
const threadBlocked = threadBlockedIntegration({ blockedThreshold: 100 });
12+
13+
Sentry.init({
14+
dsn: process.env.SENTRY_DSN,
15+
release: '1.0',
16+
debug: true,
17+
integrations: [threadBlocked],
18+
});
19+
20+
Sentry.setUser({ email: '[email protected]' });
21+
Sentry.addBreadcrumb({ message: 'important message!' });
22+
23+
function longWorkIgnored() {
24+
for (let i = 0; i < 20; i++) {
25+
const salt = crypto.randomBytes(128).toString('base64');
26+
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512');
27+
assert.ok(hash);
28+
}
29+
}
30+
31+
setTimeout(() => {
32+
threadBlocked.stopWorker();
33+
34+
setTimeout(() => {
35+
longWorkIgnored();
36+
37+
setTimeout(() => {
38+
threadBlocked.startWorker();
39+
40+
setTimeout(() => {
41+
longWork();
42+
});
43+
}, 2000);
44+
}, 2000);
45+
}, 2000);

0 commit comments

Comments
 (0)