Skip to content

Report CodeMirror view failures with context - #1322

Merged
microbit-matt-hillsdon merged 1 commit into
mainfrom
codemirror-crash-logging
Sep 10, 2026
Merged

Report CodeMirror view failures with context#1322
microbit-matt-hillsdon merged 1 commit into
mainfrom
codemirror-crash-logging

Conversation

@microbit-matt-hillsdon

Copy link
Copy Markdown
Collaborator

EditorView.update applies the new state before it redraws and does not roll back if the redraw throws, so one exception leaves the view out of step with the document and every later keystroke, click and measure throws too. Sentry then receives hundreds of follow-up events that all look alike and carry nothing to identify the first failure.

Wrap dispatchTransactions and register an exceptionSink so both the uncaught update failures and the errors CodeMirror catches itself are reported through Logging with context: user events, change spans (positions and lengths only), document versus tile-tree length, viewport, selection, composition state, navigator.language and the preceding input events as kinds without characters.

Logging.error gains an optional context object, forwarded to Sentry as extra data.

EditorView.update applies the new state before it redraws and does not
roll back if the redraw throws, so one exception leaves the view out of
step with the document and every later keystroke, click and measure
throws too. Sentry then receives hundreds of follow-up events that all
look alike and carry nothing to identify the first failure.

Wrap dispatchTransactions and register an exceptionSink so both the
uncaught update failures and the errors CodeMirror catches itself are
reported through Logging with context: user events, change spans
(positions and lengths only), document versus tile-tree length,
viewport, selection, composition state, navigator.language and the
preceding input events as kinds without characters.

Logging.error gains an optional context object, forwarded to Sentry as
extra data.
@github-actions

Copy link
Copy Markdown

@microbit-matt-hillsdon

Copy link
Copy Markdown
Collaborator Author

Once on staging we can e2e test this with a current crash, though it's really motivated by the tile-related ones we can't reproduce yet. Crash: https://code.haverbeke.berlin/codemirror/dev/issues/1751

@microbit-matt-hillsdon
microbit-matt-hillsdon added this pull request to stack #1324 September 10, 2026 12:37

@microbit-grace microbit-grace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@microbit-matt-hillsdon
microbit-matt-hillsdon merged commit 9717ab2 into main Sep 10, 2026
2 checks passed
@microbit-matt-hillsdon

Copy link
Copy Markdown
Collaborator Author

Triggered the known bug on staging and got good data back:

phase                 update
userEvents            input.type.compose.start
changes               0-181+1
startDocLength        181
docLength             1
tileLength            181
stateAdvanced         true
composing             true
compositionStarted    true
recentInput           mousedown-5339ms keydown:Meta-4944ms keydown:char-4785ms
                      keydown:Process-11ms compositionstart-11ms
                      beforeinput:insertCompositionText-9ms

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.

2 participants