Skip to content

Remove the dynamicRequire hack to fix scope memory leak #2515

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 1 commit into from
Mar 26, 2020
Merged
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
15 changes: 2 additions & 13 deletions packages/hub/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ import {
SpanContext,
User,
} from '@sentry/types';
import {
consoleSandbox,
dynamicRequire,
getGlobalObject,
isNodeEnv,
logger,
timestampWithMs,
uuid4,
} from '@sentry/utils';
import { consoleSandbox, getGlobalObject, isNodeEnv, logger, timestampWithMs, uuid4 } from '@sentry/utils';

import { Carrier, Layer } from './interfaces';
import { Scope } from './scope';
Expand Down Expand Up @@ -462,10 +454,7 @@ export function getCurrentHub(): Hub {
*/
function getHubFromActiveDomain(registry: Carrier): Hub {
try {
// We need to use `dynamicRequire` because `require` on it's own will be optimized by webpack.
// We do not want this to happen, we need to try to `require` the domain node module and fail if we are in browser
// for example so we do not have to shim it and use `getCurrentHub` universally.
const domain = dynamicRequire(module, 'domain');
const domain = require('domain');
const activeDomain = domain.active;

// If there no active domain, just return global hub
Expand Down