@@ -9,6 +9,10 @@ a threshold, JavaScript stack traces can be captured. The heartbeats can
99optionally include state information which is included with the corresponding
1010stack trace.
1111
12+ This native module is used for Sentry's
13+ [ Event Loop Blocked Detection] ( https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/event-loop-block/ )
14+ feature.
15+
1216## Basic Usage
1317
1418### 1. Register threads you want to monitor
@@ -38,58 +42,62 @@ Stack traces show where each thread is currently executing:
3842
3943``` js
4044{
41- ' 0' : [
42- {
43- function: ' from' ,
44- filename: ' node:buffer' ,
45- lineno: 298 ,
46- colno: 28
47- },
48- {
49- function: ' pbkdf2Sync' ,
50- filename: ' node:internal/crypto/pbkdf2' ,
51- lineno: 78 ,
52- colno: 17
53- },
54- {
55- function: ' longWork' ,
56- filename: ' /app/test.js' ,
57- lineno: 20 ,
58- colno: 29
59- },
60- {
61- function: ' ?' ,
62- filename: ' /app/test.js' ,
63- lineno: 24 ,
64- colno: 1
65- }
66- ],
67- ' 2' : [
68- {
69- function: ' from' ,
70- filename: ' node:buffer' ,
71- lineno: 298 ,
72- colno: 28
73- },
74- {
75- function: ' pbkdf2Sync' ,
76- filename: ' node:internal/crypto/pbkdf2' ,
77- lineno: 78 ,
78- colno: 17
79- },
80- {
81- function: ' longWork' ,
82- filename: ' /app/worker.js' ,
83- lineno: 10 ,
84- colno: 29
85- },
86- {
87- function: ' ?' ,
88- filename: ' /app/worker.js' ,
89- lineno: 14 ,
90- colno: 1
91- }
92- ]
45+ ' 0' : { // Main thread has ID '0'
46+ frames : [
47+ {
48+ function: ' from' ,
49+ filename: ' node:buffer' ,
50+ lineno: 298 ,
51+ colno: 28
52+ },
53+ {
54+ function: ' pbkdf2Sync' ,
55+ filename: ' node:internal/crypto/pbkdf2' ,
56+ lineno: 78 ,
57+ colno: 17
58+ },
59+ {
60+ function: ' longWork' ,
61+ filename: ' /app/test.js' ,
62+ lineno: 20 ,
63+ colno: 29
64+ },
65+ {
66+ function: ' ?' ,
67+ filename: ' /app/test.js' ,
68+ lineno: 24 ,
69+ colno: 1
70+ }
71+ ]
72+ },
73+ ' 2' : { // Worker thread
74+ frames : [
75+ {
76+ function: ' from' ,
77+ filename: ' node:buffer' ,
78+ lineno: 298 ,
79+ colno: 28
80+ },
81+ {
82+ function: ' pbkdf2Sync' ,
83+ filename: ' node:internal/crypto/pbkdf2' ,
84+ lineno: 78 ,
85+ colno: 17
86+ },
87+ {
88+ function: ' longWork' ,
89+ filename: ' /app/worker.js' ,
90+ lineno: 10 ,
91+ colno: 29
92+ },
93+ {
94+ function: ' ?' ,
95+ filename: ' /app/worker.js' ,
96+ lineno: 14 ,
97+ colno: 1
98+ }
99+ ]
100+ }
93101}
94102```
95103
@@ -179,12 +187,17 @@ type StackFrame = {
179187};
180188```
181189
182- #### ` threadPoll<State>(state?: State): void `
190+ #### ` threadPoll<State>(state?: State, disableLastSeen?: boolean ): void `
183191
184192Sends a heartbeat from the current thread with optional state information. The
185193state object will be serialized and included as a JavaScript object with the
186194corresponding stack trace.
187195
196+ - ` state ` (optional): An object containing state information to include with the
197+ stack trace.
198+ - ` disableLastSeen ` (optional): If ` true ` , disables the tracking of the last
199+ seen time for this thread.
200+
188201#### ` getThreadsLastSeen(): Record<string, number> `
189202
190203Returns the time in milliseconds since each registered thread called
0 commit comments