-
Notifications
You must be signed in to change notification settings - Fork 1k
prevent crashing on shadow DOM elements #857
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
prevent crashing on shadow DOM elements #857
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Implemented graceful error handling for shadow DOM elements to prevent crashes when accessing unsupported elements in the shadow DOM.
- Added check in
lib/handlers/observeHandler.ts
to detect shadow DOM elements by ID format and return 'not-supported' instead of crashing - Created new test file
evals/tasks/shadow_dom.ts
to verify graceful handling of shadow DOM interactions - Added 'shadow_dom' task to
evals/evals.config.json
under 'act' category for testing - Returns descriptive message "an element inside a shadow DOM" when encountering shadow elements
3 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile
message: `Element is inside a shadow DOM: ${elementId}`, | ||
level: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Log level 0 suggests critical error, but this is more of a warning/info. Consider using level 1 to match other similar logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanmcguire12 we need warning level logs haha
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/[email protected] ### Patch Changes - [#856](#856) [`8a43c5a`](8a43c5a) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - set download behaviour by default - [#857](#857) [`890ffcc`](890ffcc) Thanks [@miguelg719](https://github.com/miguelg719)! - return "not-supported" for elements inside the shadow-dom - [#844](#844) [`64c1072`](64c1072) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - don't automatically close tabs - [#860](#860) [`b077d3f`](b077d3f) Thanks [@miguelg719](https://github.com/miguelg719)! - Set default schema on extract options with no schema - [#842](#842) [`8bcb5d7`](8bcb5d7) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - improved handling for OS level dropdowns - [#846](#846) [`7bf10c5`](7bf10c5) Thanks [@miguelg719](https://github.com/miguelg719)! - Filter attaching to target worker / shared_worker ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies \[[`8a43c5a`](8a43c5a), [`890ffcc`](890ffcc), [`64c1072`](64c1072), [`b077d3f`](b077d3f), [`8bcb5d7`](8bcb5d7), [`7bf10c5`](7bf10c5)]: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies \[[`8a43c5a`](8a43c5a), [`890ffcc`](890ffcc), [`64c1072`](64c1072), [`b077d3f`](b077d3f), [`8bcb5d7`](8bcb5d7), [`7bf10c5`](7bf10c5)]: - @browserbasehq/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
why
TypeError: Cannot read properties of undefined (reading 'replace')
what changed
ObserveHandler
to check if the returned ID contains-
, which indicates that it will be present in ouridToXpath
mapping-
, then we log an error, and return"not-supported"
as the selector, and"an element inside a shadow DOM"
as the descriptiontest plan
"not-supported"
as the selector, and"an element inside a shadow DOM"
for elements that exist inside the shadow dom