codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.94k stars 377 forks source link

MergeView: crashes browser tab for large files #1382

Closed mikewesthad closed 6 months ago

mikewesthad commented 6 months ago

Describe the issue

Hi!

I'm running into a problem where passing a large file to the MergeView plugin crashes the browser tab (or rather it causes the process to lock up long enough that the browser considers the tab to be hanging). This is a common issue in projects with package-lock type files. Here's a stripped down example using the "try CM" page.

Browser and platform

No response

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtNZXJnZVZpZXd9IGZyb20gIkBjb2RlbWlycm9yL21lcmdlIgppbXBvcnQge0VkaXRvclZpZXcsIGJhc2ljU2V0dXB9IGZyb20gImNvZGVtaXJyb3IiCmltcG9ydCB7RWRpdG9yU3RhdGV9IGZyb20gIkBjb2RlbWlycm9yL3N0YXRlIgoKbGV0IGRvYyA9IGB0YC5yZXBlYXQoMTAwMDAwKQoKbGV0IHZpZXcgPSBuZXcgTWVyZ2VWaWV3KHsKICBhOiB7CiAgICBkb2MsCiAgICBleHRlbnNpb25zOiBiYXNpY1NldHVwCiAgfSwKICBiOiB7CiAgICBkb2M6IGRvYy5yZXBsYWNlKC90L2csICJUIikgKyAiXG5TaXgiLAogICAgZXh0ZW5zaW9uczogWwogICAgICBiYXNpY1NldHVwLAogICAgICBFZGl0b3JWaWV3LmVkaXRhYmxlLm9mKGZhbHNlKSwKICAgICAgRWRpdG9yU3RhdGUucmVhZE9ubHkub2YodHJ1ZSkKICAgIF0KICB9LAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQo=

marijnh commented 6 months ago

It appears patch 33e1998c59b5aec56965 accidentally removed the default limit on diff sizes, and this is causing the diff code to do a humongous amount of work. Attached patch fixes that.

mikewesthad commented 6 months ago

Thank you!