Skip to content
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

fix(core): Do not run setup for integration on client multiple times #10116

Merged
merged 1 commit into from Jan 9, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 9, 2024

Currently, if you do:

const myIntegration = new InboundFilters();
const myIntegration2 = new InboundFilters();
const myIntegration3 = new InboundFilters();

client.addIntegration(myIntegration);
client.addIntegration(myIntegration2);
client.addIntegration(myIntegration3);

All of these will have their setup hooks called, and thus they will be initialized multiple times. However, all but the last will be discarded from the client and not be accessible anymore via e.g. getIntegration() or similar.

This used to not matter because everything was guarded through setupOnce() anyhow, but i would say this is more of a bug and not really expected.

With this change, an integration can only be added to a client once, if you try to add it again it will noop.

@mydea mydea self-assigned this Jan 9, 2024
Currently, if you do:

```js
const myIntegration = new InboundFilters();
const myIntegration2 = new InboundFilters();
const myIntegration3 = new InboundFilters();

client.addIntegration(myIntegration);
client.addIntegration(myIntegration2);
client.addIntegration(myIntegration3);
```

All of these will have their `setup` hooks called, and thus they will be initialized multiple times. However, all but the last will be discarded from the client and not be accessible anymore via e.g. `getIntegration()` or similar.

This used to not matter because everything was guarded through `setupOnce()` anyhow, but i would say this is more of a bug and not really expected.

With this change, an integration can only be added to a client once, if you try to add it again it will noop.
Copy link
Contributor

github-actions bot commented Jan 9, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 76.61 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 67.98 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 61.6 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 32.23 KB (+0.14% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 30.73 KB (+0.09% 🔺)
@sentry/browser - Webpack (gzipped) 22.09 KB (+0.12% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 74.23 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 65.86 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 32.02 KB (+0.07% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 23.77 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 206.85 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 96.71 KB (+0.06% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 70.95 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 34.99 KB (+0.07% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 68.34 KB (+0.06% 🔺)
@sentry/react - Webpack (gzipped) 22.12 KB (+0.12% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 85.07 KB (+0.05% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 49.43 KB (+0.09% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 16.74 KB (0%)

@mydea mydea merged commit 15ab8ee into develop Jan 9, 2024
95 checks passed
@mydea mydea deleted the fn/setupIntegrationFix branch January 9, 2024 14:54
AbhiPrasad pushed a commit that referenced this pull request Jan 11, 2024
…)` (#10118)

This adds a new `client.init()` method to be called instead of
`client.setupIntegrations()`.

Note that this method simply initializes the integrations always, and
depends on the check that we don't add integrations multiple times.

This also has a bit of a different semantic, dropping the `force`
argument in favor of just calling `addIntegration()` again - this
depends on #10116 to
really work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants