Skip to content

feat(record): Allow callbackWrapper to attach a __source__ property to exceptions#111

Closed
billyvg wants to merge 2 commits intosentry-v2from
fix-insert-rule-catching-errors
Closed

feat(record): Allow callbackWrapper to attach a __source__ property to exceptions#111
billyvg wants to merge 2 commits intosentry-v2from
fix-insert-rule-catching-errors

Conversation

@billyvg
Copy link
Copy Markdown
Member

@billyvg billyvg commented Oct 12, 2023

Allow callbackWrapper to attach an optional __source__ property to a caught exception. This will allow downstream errorHandlers to decide to re-throw an exception based on the source type.

Needed to address getsentry/sentry-javascript#9170

…ty to exceptions

Allow `callbackWrapper` to attach an optional `__source__` property to a caught exception. This will allow downstream errorHandlers to decide to re-throw an exception based on the source type.
@billyvg billyvg requested a review from mydea October 12, 2023 18:07
@billyvg billyvg marked this pull request as ready for review October 12, 2023 18:08
Comment on lines +33 to +35
if (errorSource) {
error.__source__ = errorSource;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since this only happens if we have errorHandler defined, this probably only affects us. I opted to make this generic so that errorHandler be the source of truth vs attaching a meta property like __allowThrow__

billyvg added a commit to getsentry/sentry-javascript that referenced this pull request Oct 12, 2023
NOTE: This requires a bump to rrweb library

Fixes an issue where the Replay integration can potentially break applications that use `styled-components`. `styled-components` [relies on an exception being throw](https://github.com/styled-components/styled-components/blob/b7b374bb1ceff1699f7035b15881bc807110199a/packages/styled-components/src/sheet/Tag.ts#L32-L40) for CSS rules that are not supported by the browser engine. However, our SDK suppresses any exceptions thrown from within rrweb, so `styled-components` assumes that an unsupported rule was inserted successfully and increases a rule index, which causes following inserted rules to fail due to an out-of-bounds error.

getsentry/rrweb#111 introduces a change the adds metadata to exceptions that occur when calling `insertRule`, and this PR will re-throw those exceptions that will then bubble up to `styled-components`.

Fixes #9170
@billyvg
Copy link
Copy Markdown
Member Author

billyvg commented Oct 12, 2023

Actually, we probably don't need this as we should just re-throw error in our Replay SDK.

@billyvg billyvg closed this Oct 12, 2023
@mydea mydea deleted the fix-insert-rule-catching-errors branch October 13, 2023 06:57
mydea pushed a commit to getsentry/sentry-javascript that referenced this pull request Oct 13, 2023
NOTE: This requires a bump to rrweb library

Fixes an issue where the Replay integration can potentially break applications that use `styled-components`. `styled-components` [relies on an exception being throw](https://github.com/styled-components/styled-components/blob/b7b374bb1ceff1699f7035b15881bc807110199a/packages/styled-components/src/sheet/Tag.ts#L32-L40) for CSS rules that are not supported by the browser engine. However, our SDK suppresses any exceptions thrown from within rrweb, so `styled-components` assumes that an unsupported rule was inserted successfully and increases a rule index, which causes following inserted rules to fail due to an out-of-bounds error.

getsentry/rrweb#111 introduces a change the adds metadata to exceptions that occur when calling `insertRule`, and this PR will re-throw those exceptions that will then bubble up to `styled-components`.

Fixes #9170
chargome added a commit that referenced this pull request Mar 31, 2026
Bump the core build/test tooling across all workspace packages:

- **vite** ^5.2.8 → ^6.4.1
- **vitest** ^1.4.0 → ^2.1.9
- **vite-plugin-dts** ^3.8.1 → ^4.5.4
- **rollup-plugin-terser** (deprecated) → **@rollup/plugin-terser** in
rrweb-worker

Added `cssFileName: 'style'` to the shared vite config to preserve the
`style.css` output filename (Vite 6 changed the default to
package-name-based).

### Dependabot alerts resolved

**Fully resolved** (vulnerable version completely removed from
lockfile):

| Alert | Severity | Package | Summary |
|-------|----------|---------|---------|
| #113 | CRITICAL | `vitest` | Remote Code Execution when accessing a
malicious website while Vitest API server is listening |
| #203 | HIGH | `rollup` | Rollup 4 has Arbitrary File Write via Path
Traversal |
| #110 | MEDIUM | `vue-template-compiler` | Client-side XSS (no fix
available — removed by vite-plugin-dts v4 dropping the dependency) |

**Partially resolved** (some vulnerable entries removed, but package
still exists via other dependency chains):

| Alert | Severity | Package | Remaining source |
|-------|----------|---------|-----------------|
| #154, #146, #145, #141, #140, #139, #138, #126, #111 | MEDIUM/LOW |
`vite` | `@sveltejs/vite-plugin-svelte@3` still pulls in vite@5 (needs
Svelte 5 upgrade) |
| #114 | MEDIUM | `esbuild` | `esbuild-plugin-umd-wrapper` still uses
esbuild@0.18 |
| #214 | HIGH | `serialize-javascript` | webpack (via `@size-limit`)
still pulls in v6 |
| #105, #104 | MEDIUM | `nanoid` | postcss (via vite internally) still
uses nanoid@3 |
| #165, #155 | HIGH/MEDIUM | `validator` | `@microsoft/api-extractor`
(via vite-plugin-dts) — needs further investigation |

The partially resolved alerts will be addressed in later phases (Svelte
5 upgrade, @size-limit bump, mop-up).

closes
https://linear.app/getsentry/issue/SDK-1095/bump-vitest-vite-56-1-critical-7-alerts

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: chargome <chargome@users.noreply.github.com>
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.

1 participant