@@ -66,6 +66,7 @@ const INTEGRATION_NAME = 'Anr';
66
66
67
67
type AnrInternal = { startWorker : ( ) => void ; stopWorker : ( ) => void } ;
68
68
69
+ // eslint-disable-next-line deprecation/deprecation
69
70
const _anrIntegration = ( ( options : Partial < AnrIntegrationOptions > = { } ) => {
70
71
if ( NODE_VERSION . major < 16 || ( NODE_VERSION . major === 16 && NODE_VERSION . minor < 17 ) ) {
71
72
throw new Error ( 'ANR detection requires Node 16.17.0 or later' ) ;
@@ -114,8 +115,45 @@ const _anrIntegration = ((options: Partial<AnrIntegrationOptions> = {}) => {
114
115
} as Integration & AnrInternal ;
115
116
} ) satisfies IntegrationFn ;
116
117
118
+ // eslint-disable-next-line deprecation/deprecation
117
119
type AnrReturn = ( options ?: Partial < AnrIntegrationOptions > ) => Integration & AnrInternal ;
118
120
121
+ /**
122
+ * Application Not Responding (ANR) integration for Node.js applications.
123
+ *
124
+ * @deprecated The ANR integration has been deprecated. Use `eventLoopBlockIntegration` from `@sentry/node-native` instead.
125
+ *
126
+ * Detects when the Node.js main thread event loop is blocked for more than the configured
127
+ * threshold (5 seconds by default) and reports these as Sentry events.
128
+ *
129
+ * ANR detection uses a worker thread to monitor the event loop in the main app thread.
130
+ * The main app thread sends a heartbeat message to the ANR worker thread every 50ms by default.
131
+ * If the ANR worker does not receive a heartbeat message for the configured threshold duration,
132
+ * it triggers an ANR event.
133
+ *
134
+ * - Node.js 16.17.0 or higher
135
+ * - Only supported in the Node.js runtime (not browsers)
136
+ * - Not supported for Node.js clusters
137
+ *
138
+ * Overhead should be minimal:
139
+ * - Main thread: Only polling the ANR worker over IPC every 50ms
140
+ * - Worker thread: Consumes around 10-20 MB of RAM
141
+ * - When ANR detected: Brief pause in debugger to capture stack trace (negligible compared to the blocking)
142
+ *
143
+ * @example
144
+ * ```javascript
145
+ * Sentry.init({
146
+ * dsn: "https://examplePublicKey@o 0.ingest.sentry.io/0",
147
+ * integrations: [
148
+ * Sentry.anrIntegration({
149
+ * anrThreshold: 5000,
150
+ * captureStackTrace: true,
151
+ * pollInterval: 50,
152
+ * }),
153
+ * ],
154
+ * });
155
+ * ```
156
+ */
119
157
export const anrIntegration = defineIntegration ( _anrIntegration ) as AnrReturn ;
120
158
121
159
/**
@@ -125,6 +163,7 @@ export const anrIntegration = defineIntegration(_anrIntegration) as AnrReturn;
125
163
*/
126
164
async function _startWorker (
127
165
client : NodeClient ,
166
+ // eslint-disable-next-line deprecation/deprecation
128
167
integrationOptions : Partial < AnrIntegrationOptions > ,
129
168
) : Promise < ( ) => void > {
130
169
const dsn = client . getDsn ( ) ;
@@ -229,7 +268,13 @@ async function _startWorker(
229
268
export function disableAnrDetectionForCallback < T > ( callback : ( ) => T ) : T ;
230
269
export function disableAnrDetectionForCallback < T > ( callback : ( ) => Promise < T > ) : Promise < T > ;
231
270
/**
232
- * Disables ANR detection for the duration of the callback
271
+ * Temporarily disables ANR detection for the duration of a callback function.
272
+ *
273
+ * This utility function allows you to disable ANR detection during operations that
274
+ * are expected to block the event loop, such as intensive computational tasks or
275
+ * synchronous I/O operations.
276
+ *
277
+ * @deprecated The ANR integration has been deprecated. Use `eventLoopBlockIntegration` from `@sentry/node-native` instead.
233
278
*/
234
279
export function disableAnrDetectionForCallback < T > ( callback : ( ) => T | Promise < T > ) : T | Promise < T > {
235
280
const integration = getClient ( ) ?. getIntegrationByName ( INTEGRATION_NAME ) as AnrInternal | undefined ;
0 commit comments