Skip to content

fix: clone sentryConfig before mutation#28

Open
JoshuaKGoldberg wants to merge 1 commit into
mainfrom
clone-config-options-before-use
Open

fix: clone sentryConfig before mutation#28
JoshuaKGoldberg wants to merge 1 commit into
mainfrom
clone-config-options-before-use

Conversation

@JoshuaKGoldberg

Copy link
Copy Markdown
Member

Fixes the crash discovered in getsentry/sentry#110568: Sentry's Jest unit tests normally run in worker processes. Modifying the shared config object in them is fine because they're already copies of the original. But when switching to in-band, the environment needs to manually copy them.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread createEnvironment.js
const [config, context] = args;

this.options = config.projectConfig.testEnvironmentOptions?.sentryConfig;
this.options = structuredClone(config.projectConfig.testEnvironmentOptions?.sentryConfig)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

structuredClone throws on configs containing functions

Medium Severity

structuredClone throws a DataCloneError if the sentryConfig object (or its nested init property) contains any function values. Sentry's init options commonly include callbacks like beforeSend, tracesSampler, beforeBreadcrumb, or integrations as a function. Users passing any of these will now get a runtime error that didn't exist before this change. A shallow spread of only the mutated paths (init and init.integrations) would avoid this while still preventing the shared-config mutation the PR intends to fix.

Fix in Cursor Fix in Web

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.

2 participants