Skip to content

feat(v8/node): Remove deprecated anr methods #10562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ enum. If you were using the `Severity` enum, you should replace it with the `Sev
The `Offline` integration has been removed in favor of the offline transport wrapper:
http://docs.sentry.io/platforms/javascript/configuration/transports/#offline-caching

## Removal of `enableAnrDetection` and `Anr` class (##10562)

The `enableAnrDetection` and `Anr` class have been removed. See the
[docs](https://docs.sentry.io/platforms/node/configuration/application-not-responding/) for more details how to migrate
to `anrIntegration`, the new integration for ANR detection.

## Other changes

- Remove `spanStatusfromHttpCode` in favour of `getSpanStatusFromHttpCode` (#10361)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const DEPENDENTS: Dependent[] = [
{
package: '@sentry/serverless',
exports: Object.keys(SentryServerless),
ignoreExports: ['cron', 'hapiErrorPlugin', 'enableAnrDetection'],
ignoreExports: ['cron', 'hapiErrorPlugin'],
},
{
package: '@sentry/sveltekit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
debug: true,
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true, anrThreshold: 100 })],
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

function longWork() {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/suites/anr/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sentry.init({
release: '1.0',
debug: true,
autoSessionTracking: false,
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true, anrThreshold: 100 })],
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

function longWork() {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/suites/anr/basic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sentry.init({
release: '1.0',
debug: true,
autoSessionTracking: false,
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true, anrThreshold: 100 })],
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

function longWork() {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/suites/anr/forked.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sentry.init({
release: '1.0',
debug: true,
autoSessionTracking: false,
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true, anrThreshold: 100 })],
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

function longWork() {
Expand Down
31 changes: 0 additions & 31 deletions dev-packages/node-integration-tests/suites/anr/legacy.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function configureSentry() {
release: '1.0',
debug: true,
autoSessionTracking: false,
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true })],
integrations: [Sentry.anrIntegration({ captureStackTrace: true })],
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function configureSentry() {
release: '1.0',
debug: true,
autoSessionTracking: false,
integrations: [new Sentry.Integrations.Anr({ captureStackTrace: true })],
integrations: [Sentry.anrIntegration({ captureStackTrace: true })],
});
}

Expand Down
5 changes: 0 additions & 5 deletions dev-packages/node-integration-tests/suites/anr/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ conditionalTest({ min: 16 })('should report ANR when event loop blocked', () =>
cleanupChildProcesses();
});

// TODO (v8): Remove this old API and this test
test('Legacy API', done => {
createRunner(__dirname, 'legacy.js').expect({ event: EXPECTED_ANR_EVENT }).start(done);
});

test('CJS', done => {
createRunner(__dirname, 'basic.js').expect({ event: EXPECTED_ANR_EVENT }).start(done);
});
Expand Down
2 changes: 0 additions & 2 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ export {
} from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';
export {
// eslint-disable-next-line deprecation/deprecation
enableAnrDetection,
// eslint-disable-next-line deprecation/deprecation
getModuleFromFilename,
DEFAULT_USER_INCLUDES,
Expand Down
3 changes: 0 additions & 3 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ import { createGetModuleFromFilename } from './module';
export const getModuleFromFilename = createGetModuleFromFilename();
export { createGetModuleFromFilename };

// eslint-disable-next-line deprecation/deprecation
export { enableAnrDetection } from './integrations/anr/legacy';

import { Integrations as CoreIntegrations } from '@sentry/core';

import * as Handlers from './handlers';
Expand Down
21 changes: 2 additions & 19 deletions packages/node/src/integrations/anr/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO (v8): This import can be removed once we only support Node with global URL
import { URL } from 'url';
import { convertIntegrationFnToClass, defineIntegration, getCurrentScope } from '@sentry/core';
import type { Client, Contexts, Event, EventHint, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import { defineIntegration, getCurrentScope } from '@sentry/core';
import type { Contexts, Event, EventHint, IntegrationFn } from '@sentry/types';
import { dynamicRequire, logger } from '@sentry/utils';
import type { Worker, WorkerOptions } from 'worker_threads';
import type { NodeClient } from '../../client';
Expand Down Expand Up @@ -70,23 +70,6 @@ const _anrIntegration = ((options: Partial<AnrIntegrationOptions> = {}) => {

export const anrIntegration = defineIntegration(_anrIntegration);

/**
* Starts a thread to detect App Not Responding (ANR) events
*
* ANR detection requires Node 16.17.0 or later
*
* @deprecated Use `anrIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const Anr = convertIntegrationFnToClass(INTEGRATION_NAME, anrIntegration) as IntegrationClass<
Integration & { setup: (client: NodeClient) => void }
> & {
new (options?: Partial<AnrIntegrationOptions>): Integration & { setup(client: Client): void };
};

// eslint-disable-next-line deprecation/deprecation
export type Anr = typeof Anr;

/**
* Starts the ANR worker thread
*/
Expand Down
33 changes: 0 additions & 33 deletions packages/node/src/integrations/anr/legacy.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ export { Context } from './context';
export { RequestData } from '@sentry/core';
export { Undici } from './undici';
export { Spotlight } from './spotlight';
export { Anr } from './anr';
export { Hapi } from './hapi';
2 changes: 0 additions & 2 deletions packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ export {
createGetModuleFromFilename,
hapiErrorPlugin,
runWithAsyncContext,
// eslint-disable-next-line deprecation/deprecation
enableAnrDetection,
} from '@sentry/node';

// Keeping the `*` exports for backwards compatibility and types
Expand Down
2 changes: 0 additions & 2 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ export {
hapiErrorPlugin,
metrics,
runWithAsyncContext,
// eslint-disable-next-line deprecation/deprecation
enableAnrDetection,
} from '@sentry/node';

// We can still leave this for the carrier init and type exports
Expand Down