File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ type ThreadBlockedReturn = (options?: Partial<ThreadBlockedIntegrationOptions>)
73
73
* Monitors the Node.js event loop for blocking behavior and reports blocked events to Sentry.
74
74
*
75
75
* Uses a background worker thread to detect when the main thread is blocked for longer than
76
- * the configured threshold (default: 5 seconds ).
76
+ * the configured threshold (default: 1 second ).
77
77
*
78
78
* When instrumenting via the `--import` flag, this integration will
79
79
* automatically monitor all worker threads as well.
@@ -213,6 +213,9 @@ export function disableBlockedDetectionForCallback<T>(callback: () => T | Promis
213
213
return result . finally ( ( ) => integration . start ( ) ) ;
214
214
}
215
215
216
- integration . start ( ) ;
217
- return result ;
216
+ try {
217
+ return result ;
218
+ } finally {
219
+ integration . start ( ) ;
220
+ }
218
221
}
Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ function getExceptionAndThreads(
217
217
} ;
218
218
}
219
219
220
- async function sendAnrEvent ( crashedThreadId : string ) : Promise < void > {
220
+ async function sendBlockEvent ( crashedThreadId : string ) : Promise < void > {
221
221
if ( isRateLimited ( ) ) {
222
222
return ;
223
223
}
@@ -230,7 +230,11 @@ async function sendAnrEvent(crashedThreadId: string): Promise<void> {
230
230
return ;
231
231
}
232
232
233
- await sendAbnormalSession ( crashedThread . state ?. session ) ;
233
+ try {
234
+ await sendAbnormalSession ( crashedThread . state ?. session ) ;
235
+ } catch ( error ) {
236
+ log ( `Failed to send abnormal session for thread '${ crashedThreadId } ':` , error ) ;
237
+ }
234
238
235
239
log ( 'Sending event' ) ;
236
240
@@ -267,10 +271,14 @@ setInterval(async () => {
267
271
continue ;
268
272
}
269
273
270
- log ( `Detected ANR for thread '${ threadId } ' with last seen time ${ time } ms` ) ;
274
+ log ( `Blocked thread detected '${ threadId } ' last polled ${ time } ms ago. ` ) ;
271
275
triggeredThreads . add ( threadId ) ;
272
276
273
- await sendAnrEvent ( threadId ) ;
277
+ try {
278
+ await sendBlockEvent ( threadId ) ;
279
+ } catch ( error ) {
280
+ log ( `Failed to send event for thread '${ threadId } ':` , error ) ;
281
+ }
274
282
} else {
275
283
triggeredThreads . delete ( threadId ) ;
276
284
}
You can’t perform that action at this time.
0 commit comments