Skip to content

fix(node): Remove circular dependency between backend and parser #3633

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 7 commits into from
Jun 2, 2021
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
3 changes: 1 addition & 2 deletions packages/eslint-config-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
},
"devDependencies": {
"eslint": "7.27.0",
"typescript": "3.7.5",
"madge": "4.0.2"
"typescript": "3.7.5"
},
"scripts": {
"link:yarn": "yarn link",
Expand Down
30 changes: 2 additions & 28 deletions packages/node/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseBackend, getCurrentHub } from '@sentry/core';
import { Event, EventHint, Mechanism, Options, Severity, Transport, TransportOptions } from '@sentry/types';
import { Event, EventHint, Mechanism, Severity, Transport, TransportOptions } from '@sentry/types';
import {
addExceptionMechanism,
addExceptionTypeValue,
Expand All @@ -13,33 +13,7 @@ import {

import { extractStackFromError, parseError, parseStack, prepareFramesForEvent } from './parsers';
import { HTTPSTransport, HTTPTransport } from './transports';

/**
* Configuration options for the Sentry Node SDK.
* @see NodeClient for more information.
*/
export interface NodeOptions extends Options {
/** Sets an optional server name (device name) */
serverName?: string;

/** Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit. */
shutdownTimeout?: number;

/** Set a HTTP proxy that should be used for outbound requests. */
httpProxy?: string;

/** Set a HTTPS proxy that should be used for outbound requests. */
httpsProxy?: string;

/** HTTPS proxy certificates path */
caCerts?: string;

/** Sets the number of context lines for each frame when loading a file. */
frameContextLines?: number;

/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
}
import { NodeOptions } from './types';

/**
* The Sentry Node SDK Backend.
Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { SessionFlusher } from '@sentry/hub';
import { Event, EventHint, RequestSessionStatus } from '@sentry/types';
import { logger } from '@sentry/utils';

import { NodeBackend, NodeOptions } from './backend';
import { NodeBackend } from './backend';
import { NodeOptions } from './types';

/**
* The Sentry Node SDK Client.
Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export {
withScope,
} from '@sentry/core';

export { NodeBackend, NodeOptions } from './backend';
export { NodeOptions } from './types';
export { NodeBackend } from './backend';
export { NodeClient } from './client';
export { defaultIntegrations, init, lastEventId, flush, close, getSentryRelease } from './sdk';
export { deepReadDirSync } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { addContextToFrame, basename, dirname, SyncPromise } from '@sentry/utils
import { readFile } from 'fs';
import { LRUMap } from 'lru_map';

import { NodeOptions } from './backend';
import * as stacktrace from './stacktrace';
import { NodeOptions } from './types';

const DEFAULT_LINES_OF_CONTEXT: number = 7;
const FILE_CONTENT_CACHE = new LRUMap<string, string | null>(100);
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { SessionStatus } from '@sentry/types';
import { getGlobalObject } from '@sentry/utils';
import * as domain from 'domain';

import { NodeOptions } from './backend';
import { NodeClient } from './client';
import { Console, Http, LinkedErrors, OnUncaughtException, OnUnhandledRejection } from './integrations';
import { NodeOptions } from './types';

export const defaultIntegrations = [
// Common
Expand Down
28 changes: 28 additions & 0 deletions packages/node/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Options } from '@sentry/types';

/**
* Configuration options for the Sentry Node SDK.
* @see NodeClient for more information.
*/
export interface NodeOptions extends Options {
/** Sets an optional server name (device name) */
serverName?: string;

/** Maximum time in milliseconds to wait to drain the request queue, before the process is allowed to exit. */
shutdownTimeout?: number;

/** Set a HTTP proxy that should be used for outbound requests. */
httpProxy?: string;

/** Set a HTTPS proxy that should be used for outbound requests. */
httpsProxy?: string;

/** HTTPS proxy certificates path */
caCerts?: string;

/** Sets the number of context lines for each frame when loading a file. */
frameContextLines?: number;

/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
}