fix(components): truncate string title to prevent crash on large strings COMPASS-10857#8249
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a Chromium renderer crash caused by rendering extremely large string values into an HTML title attribute in the BSON value UI component.
Changes:
- Caps the
titleattribute for string BSON values to a bounded length. - Adds a regression test to ensure very large strings do not propagate unbounded into
title.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/compass-components/src/components/bson-value.tsx | Truncates string title attribute value to avoid crashes from extremely large strings. |
| packages/compass-components/src/components/bson-value.spec.tsx | Adds test coverage asserting title is capped for large string inputs. |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
| }); | ||
| }); | ||
|
|
||
| it('should cap the title attribute for very large strings', function () { |
There was a problem hiding this comment.
Maybe worth an e2e tests... If bloated docs collection showed the issue, maybe we can add a spec specifically for it? Being slow is one thing, but crashing we should catch 🤔
There was a problem hiding this comment.
(doesn't need to happen in the same PR)
There was a problem hiding this comment.
Yes, worth an e2e test that loads the Bloated Documents for sure. It'll have to be a static deployment though as we don't want to be inserting and clearing a few MB documents each run I think. Merging to get this fix in while I work on it.
COMPASS-10857
Compass Data Sets ->
BloatedDocuments.Bloated documentsis a dataset that will reproduce this bug.I am not sure if this is a recent change in chromium that started this crashing, I'll look about a bit but I don't think that's any blocker. We have had the title in there for > 3 years.
We do render
titleunbounded from user content in a few other places, but on a relatively quick look it doesn't look like it's anything similar to the size of what a field can be.