Enrich incompatible update invariant messages with diagnostics#682
Merged
Conversation
* Enrich incompatible update invariant messages with diagnostics
Reformat invariant-violation messages across updateObject, updateTree,
traverse, and draftHelpers to follow a consistent broader-to-specific
shape: operation debugName, then path, then the enclosing node __typename,
then the observed value (including the incoming value's type where it can
be recovered). All path and type extraction is wrapped in try/catch since
the cache state is already corrupt when an invariant fires, and no node
keys are interpolated to avoid exposing entity identifiers.
Adds co-located unit tests for every new message with named operations and
exact-message assertions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix lint: normalize line endings and formatting
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Change files
* Defer invariant message construction to the failure path
The enriched diagnostic messages walk the data path and look up __typenames,
which is expensive. Passing them as the second argument to assert() built the
full string on every call, including the success path, causing a 7-10%
regression in the write-array benchmarks.
Guard each message-bearing assert with an explicit condition check so the
message builder only runs when the invariant actually fails, matching the
existing if (!cond) { assert(false, ...) } pattern already used in traverse.ts
and draftHelpers.ts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: vrazuvaev <vrazuvaev@microsoft.com_msteamsmdb>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📊 Benchmark Analysis Report✅ No significant performance changes detected Threshold: 5% change Updated: 2026-06-26T08:50:53.688Z |
pavelglac
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal: better error messages for invariants that may happen on incorrect manual cache operations.
Update the invariant-violation messages across
updateObject,updateTree,traverse, anddraftHelpersto follow a consistent broader-to-specific shape: