[DO NOT MERGE] feat(core): add opt-in assertion instrumentation - #6592
[DO NOT MERGE] feat(core): add opt-in assertion instrumentation#6592antonis wants to merge 11 commits into
4 issues
code-review: Found 4 issues (2 medium, 2 low)
Medium
Unvalidated `rethrowPragmas` option can crash Babel on malformed config - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:567-568`
Add a defensive Array.isArray(options.rethrowPragmas) check before calling .includes() — a non-array value (e.g., a string passed via Metro config) causes a build-time TypeError.
Module-level reportedSites set is never reset between tests - `packages/core/test/assertion.test.ts:24-27`
beforeEach clears mocks but leaves the module-level reportedSites set intact, so tests that pass siteId pollute shared state and can flake in watch mode.
Low
Overly broad node_modules path detection may skip first-party files - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:359`
filename.includes('node_modules') matches any path containing that substring, so a first-party file whose path happens to contain node_modules (e.g., node_modules_helper.js or a node_modules_workspace/ directory) can be incorrectly treated as a dependency and skipped when includeNodeModules is false or absent. This contradicts the stated intent that first-party code is instrumented by default.
Error alias fallback can throw ReferenceError in TDZ on pre-globalThis runtimes - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:485`
The hoisted Error alias falls back to bare Error when globalThis is absent. On ES6–ES2019 runtimes that support let/const TDZ but lack globalThis, a module-level let Error causes the fallback to throw ReferenceError instead of creating the alias.
⏱ 31m 24s · 4.2M in / 374.1k out · $3.98
Annotations
Check warning on line 568 in packages/core/src/js/tools/sentryAssertionBabelPlugin.ts
sentry-warden / warden: code-review
Unvalidated `rethrowPragmas` option can crash Babel on malformed config
Add a defensive `Array.isArray(options.rethrowPragmas)` check before calling `.includes()` — a non-array value (e.g., a string passed via Metro config) causes a build-time `TypeError`.
Check warning on line 27 in packages/core/test/assertion.test.ts
sentry-warden / warden: code-review
Module-level reportedSites set is never reset between tests
`beforeEach` clears mocks but leaves the module-level `reportedSites` set intact, so tests that pass `siteId` pollute shared state and can flake in watch mode.