Skip to content

Commit 92c37f5

Browse files
authored
fix: Dont wrap native modules more than once (#1629)
1 parent fc204d5 commit 92c37f5

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

CHANGELOG.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,33 @@
22

33
## Unreleased
44

5-
- [hub] fix: Scope level overwrites level on the event
6-
- [core] fix: correct sampleRate behaviour
7-
- [core] feat: RewriteFrames pluggable integration
8-
- [core] feat: Introduce stringify and debugger options in Debug integration
9-
- [core] feat: getRequestheaders should handle legacy DSNs
10-
- [core] ref: Check for node-env first and return more accurate global object
11-
- [core] ref: Remove Repo interface and repos attribute from Event
12-
- [core] ref: Check for node-env first and return more accurate global object
13-
- [core] ref: Remove Repo interface and repos attribute from Event
14-
- [core] ref: Rewrite RequestBuffer using Array instead of Set for IE10/11
15-
- [core] misc: Warn user when beforeSend doesnt return an event or null
5+
- [browser] feat: Better mechanism detection in TraceKit
166
- [browser] fix: Change loader to use getAttribute instead of dataset
177
- [browser] fix: Remove trailing commas from loader for IE10/11
18-
- [browser] feat: Better mechanism detection in TraceKit
198
- [browser] ref: Include md5 lib and transcript it to TypeScript
9+
- [browser] ref: Remove all trailing commas from integration tests cuz IE10/11
2010
- [browser] ref: Remove default transaction from browser
21-
- [browser] ref: Include md5 lib and transcript it to TypeScript
2211
- [browser] ref: Remove redundant debug.ts file from browser integrations
23-
- [browser] ref: Remove all trailing commas from integration tests cuz IE10/11
24-
- [browser] test: Run integration tests on SauceLabs
2512
- [browser] test: Fix all integration tests in IE10/11 and Android browsers
13+
- [browser] test: Run integration tests on SauceLabs
14+
- [browser] test: Stop running raven-js saucelabs tests in favour of @sentry/browser
2615
- [browser] test: Store breadcrumbs in the global variable in integration tests
2716
- [browser] test: Update polyfills for integration tests
28-
- [browser] test: Stop running raven-js saucelabs tests in favour of @sentry/browser
29-
- [node] feat: Transactions handling for RequestHandler in Express/Hapi
17+
- [build] ref: Use Mocha v4 instead of v5, as it's not supporting IE10
18+
- [core] feat: Introduce stringify and debugger options in Debug integration
19+
- [core] feat: RewriteFrames pluggable integration
20+
- [core] feat: getRequestheaders should handle legacy DSNs
21+
- [core] fix: correct sampleRate behaviour
22+
- [core] misc: Warn user when beforeSend doesnt return an event or null
23+
- [core] ref: Check for node-env first and return more accurate global object
24+
- [core] ref: Remove Repo interface and repos attribute from Event
25+
- [core] ref: Rewrite RequestBuffer using Array instead of Set for IE10/11
26+
- [hub] fix: Scope level overwrites level on the event
3027
- [node] feat: Allow requestHandler to be configured
3128
- [node] feat: Make node transactions a pluggable integration with tests
29+
- [node] feat: Transactions handling for RequestHandler in Express/Hapi
30+
- [node] fix: Dont wrap native modules more than once to prevent leaks
3231
- [utils] ref: implemented includes, assign and isNaN polyfills
33-
- [build] ref: Use Mocha v4 instead of v5, as it's not supporting IE10
3432

3533
## 4.0.6
3634

packages/node/src/integrations/console.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ function loadWrapper(nativeModule: any): any {
1414
return function(moduleId: string): any {
1515
const originalModule = originalLoad.apply(nativeModule, arguments);
1616

17-
if (moduleId !== 'console') {
17+
if (moduleId !== 'console' || originalModule.__sentry__) {
1818
return originalModule;
1919
}
2020

2121
['debug', 'info', 'warn', 'error', 'log'].forEach(consoleWrapper(originalModule));
2222

23+
originalModule.__sentry__ = true;
2324
return originalModule;
2425
};
2526
};

packages/node/src/integrations/http.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function loadWrapper(nativeModule: any): any {
4747
return function(this: SentryRequest, moduleId: string): any {
4848
const originalModule = originalLoad.apply(nativeModule, arguments);
4949

50-
if (moduleId !== 'http') {
50+
if (moduleId !== 'http' || originalModule.__sentry__) {
5151
return originalModule;
5252
}
5353

@@ -93,6 +93,7 @@ function loadWrapper(nativeModule: any): any {
9393
};
9494
});
9595

96+
originalModule.__sentry__ = true;
9697
return originalModule;
9798
};
9899
};

packages/utils/src/object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function clone<T>(object: T): T {
153153
*/
154154

155155
export function fill(source: { [key: string]: any }, name: string, replacement: (...args: any[]) => any): void {
156-
if (!(name in source)) {
156+
if (!(name in source) || (source[name] as SentryWrappedFunction).__sentry__) {
157157
return;
158158
}
159159
const original = source[name] as () => any;

0 commit comments

Comments
 (0)