@@ -66,6 +66,7 @@ const INTEGRATION_NAME = 'Anr';
6666
6767type AnrInternal = { startWorker : ( ) => void ; stopWorker : ( ) => void } ;
6868
69+ // eslint-disable-next-line deprecation/deprecation
6970const _anrIntegration = ( ( options : Partial < AnrIntegrationOptions > = { } ) => {
7071 if ( NODE_VERSION . major < 16 || ( NODE_VERSION . major === 16 && NODE_VERSION . minor < 17 ) ) {
7172 throw new Error ( 'ANR detection requires Node 16.17.0 or later' ) ;
@@ -114,8 +115,45 @@ const _anrIntegration = ((options: Partial<AnrIntegrationOptions> = {}) => {
114115 } as Integration & AnrInternal ;
115116} ) satisfies IntegrationFn ;
116117
118+ // eslint-disable-next-line deprecation/deprecation
117119type AnrReturn = ( options ?: Partial < AnrIntegrationOptions > ) => Integration & AnrInternal ;
118120
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+ */
119157export const anrIntegration = defineIntegration ( _anrIntegration ) as AnrReturn ;
120158
121159/**
@@ -125,6 +163,7 @@ export const anrIntegration = defineIntegration(_anrIntegration) as AnrReturn;
125163 */
126164async function _startWorker (
127165 client : NodeClient ,
166+ // eslint-disable-next-line deprecation/deprecation
128167 integrationOptions : Partial < AnrIntegrationOptions > ,
129168) : Promise < ( ) => void > {
130169 const dsn = client . getDsn ( ) ;
@@ -229,7 +268,13 @@ async function _startWorker(
229268export function disableAnrDetectionForCallback < T > ( callback : ( ) => T ) : T ;
230269export function disableAnrDetectionForCallback < T > ( callback : ( ) => Promise < T > ) : Promise < T > ;
231270/**
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.
233278 */
234279export function disableAnrDetectionForCallback < T > ( callback : ( ) => T | Promise < T > ) : T | Promise < T > {
235280 const integration = getClient ( ) ?. getIntegrationByName ( INTEGRATION_NAME ) as AnrInternal | undefined ;
0 commit comments