Skip to content

Commit ce9637e

Browse files
author
Steven Weingärtner
committed
fix: only initialize sentry if it's not already happened
This should reduce memory usage and hopefully fix a memory leak
1 parent e16ed58 commit ce9637e

File tree

1 file changed

+13
-11
lines changed
  • packages/node-logger-plugin-sentry/src

1 file changed

+13
-11
lines changed

packages/node-logger-plugin-sentry/src/index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ export default class PluginSentry {
3535
...rest,
3636
};
3737

38-
Sentry.init({
39-
debug: this.config.sentry.debug,
40-
dsn: this.config.sentry.dsn,
41-
environment: this.config.sentry.environment,
42-
release: this.config.sentry.release,
43-
maxBreadcrumbs: this.config.sentry.maxBreadcrumbs,
44-
integrations(integrations) {
45-
return integrations
46-
.filter(integration => integration.name !== 'Console');
47-
},
48-
});
38+
if (!Sentry.isInitialized()) {
39+
Sentry.init({
40+
debug: this.config.sentry.debug,
41+
dsn: this.config.sentry.dsn,
42+
environment: this.config.sentry.environment,
43+
release: this.config.sentry.release,
44+
maxBreadcrumbs: this.config.sentry.maxBreadcrumbs,
45+
integrations(integrations) {
46+
return integrations
47+
.filter(integration => integration.name !== 'Console');
48+
},
49+
});
50+
}
4951
}
5052

5153
log(event) {

0 commit comments

Comments
 (0)