fix: clear restartTimeout on destroy #77

Merged
Cherry merged 1 commit from fix/invalid-child-in-posBefore into main 2026-01-05 07:42:07 +01:00
Cherry commented 2026-01-04 19:12:13 +01:00 (Migrated from github.com)

In production, we create and destroy CodeMirror instances somewhat regularly, and see this error in our Sentry reports quite a lot: RangeError: Invalid child in posBefore.

Tracing it back, what seems to be happening is the following: The destroy() method clears hoverTimeout but not restartTimeout. So if a restartTimeout was scheduled before destruction, it fires on the old/destroyed view, causing startHover()posAtCoords() to fail with stale DOM references.

By clearing restartTimeout on destroy, this seems to resolve the rare race condition.

In production, we create and destroy CodeMirror instances somewhat regularly, and see this error in our Sentry reports quite a lot: `RangeError: Invalid child in posBefore`. Tracing it back, what seems to be happening is the following: The destroy() method clears `hoverTimeout` but not `restartTimeout`. So if a `restartTimeout` was scheduled before destruction, it fires on the old/destroyed view, causing `startHover()` → `posAtCoords()` to fail with stale DOM references. By clearing `restartTimeout` on destroy, this seems to resolve the rare race condition.
marijnh commented 2026-01-05 07:41:01 +01:00 (Migrated from github.com)

Thanks for fixing that!

Thanks for fixing that!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/view!77
No description provided.