Skip to content

Commit 2c4f4b8

Browse files
authored
fix(node): Remove circular dependency between backend and parser (#3633)
When running madge on `@sentry/node`: $ madge --circular src/index.ts Processed 10 files (698ms) (8 warnings) ✖ Found 1 circular dependency! 1) backend.ts > parsers.ts To remove the circular relationship between backend and parsers, we extract the NodeOptions type into a separate types.ts file.
1 parent a29510c commit 2c4f4b8

File tree

7 files changed

+37
-34
lines changed

7 files changed

+37
-34
lines changed

packages/eslint-config-sdk/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
},
3535
"devDependencies": {
3636
"eslint": "7.27.0",
37-
"typescript": "3.7.5",
38-
"madge": "4.0.2"
37+
"typescript": "3.7.5"
3938
},
4039
"scripts": {
4140
"link:yarn": "yarn link",

packages/node/src/backend.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BaseBackend, getCurrentHub } from '@sentry/core';
2-
import { Event, EventHint, Mechanism, Options, Severity, Transport, TransportOptions } from '@sentry/types';
2+
import { Event, EventHint, Mechanism, Severity, Transport, TransportOptions } from '@sentry/types';
33
import {
44
addExceptionMechanism,
55
addExceptionTypeValue,
@@ -13,33 +13,7 @@ import {
1313

1414
import { extractStackFromError, parseError, parseStack, prepareFramesForEvent } from './parsers';
1515
import { HTTPSTransport, HTTPTransport } from './transports';
16-
17-
/**
18-
* Configuration options for the Sentry Node SDK.
19-
* @see NodeClient for more information.
20-
*/
21-
export interface NodeOptions extends Options {
22-
/** Sets an optional server name (device name) */
23-
serverName?: string;
24-
25-
/** Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit. */
26-
shutdownTimeout?: number;
27-
28-
/** Set a HTTP proxy that should be used for outbound requests. */
29-
httpProxy?: string;
30-
31-
/** Set a HTTPS proxy that should be used for outbound requests. */
32-
httpsProxy?: string;
33-
34-
/** HTTPS proxy certificates path */
35-
caCerts?: string;
36-
37-
/** Sets the number of context lines for each frame when loading a file. */
38-
frameContextLines?: number;
39-
40-
/** Callback that is executed when a fatal global error occurs. */
41-
onFatalError?(error: Error): void;
42-
}
16+
import { NodeOptions } from './types';
4317

4418
/**
4519
* The Sentry Node SDK Backend.

packages/node/src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { SessionFlusher } from '@sentry/hub';
33
import { Event, EventHint, RequestSessionStatus } from '@sentry/types';
44
import { logger } from '@sentry/utils';
55

6-
import { NodeBackend, NodeOptions } from './backend';
6+
import { NodeBackend } from './backend';
7+
import { NodeOptions } from './types';
78

89
/**
910
* The Sentry Node SDK Client.

packages/node/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export {
3838
withScope,
3939
} from '@sentry/core';
4040

41-
export { NodeBackend, NodeOptions } from './backend';
41+
export { NodeOptions } from './types';
42+
export { NodeBackend } from './backend';
4243
export { NodeClient } from './client';
4344
export { defaultIntegrations, init, lastEventId, flush, close, getSentryRelease } from './sdk';
4445
export { deepReadDirSync } from './utils';

packages/node/src/parsers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { addContextToFrame, basename, dirname, SyncPromise } from '@sentry/utils
33
import { readFile } from 'fs';
44
import { LRUMap } from 'lru_map';
55

6-
import { NodeOptions } from './backend';
76
import * as stacktrace from './stacktrace';
7+
import { NodeOptions } from './types';
88

99
const DEFAULT_LINES_OF_CONTEXT: number = 7;
1010
const FILE_CONTENT_CACHE = new LRUMap<string, string | null>(100);

packages/node/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { SessionStatus } from '@sentry/types';
44
import { getGlobalObject } from '@sentry/utils';
55
import * as domain from 'domain';
66

7-
import { NodeOptions } from './backend';
87
import { NodeClient } from './client';
98
import { Console, Http, LinkedErrors, OnUncaughtException, OnUnhandledRejection } from './integrations';
9+
import { NodeOptions } from './types';
1010

1111
export const defaultIntegrations = [
1212
// Common

packages/node/src/types.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Options } from '@sentry/types';
2+
3+
/**
4+
* Configuration options for the Sentry Node SDK.
5+
* @see NodeClient for more information.
6+
*/
7+
export interface NodeOptions extends Options {
8+
/** Sets an optional server name (device name) */
9+
serverName?: string;
10+
11+
/** Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit. */
12+
shutdownTimeout?: number;
13+
14+
/** Set a HTTP proxy that should be used for outbound requests. */
15+
httpProxy?: string;
16+
17+
/** Set a HTTPS proxy that should be used for outbound requests. */
18+
httpsProxy?: string;
19+
20+
/** HTTPS proxy certificates path */
21+
caCerts?: string;
22+
23+
/** Sets the number of context lines for each frame when loading a file. */
24+
frameContextLines?: number;
25+
26+
/** Callback that is executed when a fatal global error occurs. */
27+
onFatalError?(error: Error): void;
28+
}

0 commit comments

Comments
 (0)