Diagnostics

Look up stable diagnostic codes for open, save, edit, review, font, and collaboration failures.

The editor reports open, save, edit, review, font, and collaboration events as diagnostics. This page lists every stable failure code with its cause and action.

Capture diagnostics

Register a module with an onDiagnostic listener when you create the editor:

import { DocxEditor } from '@docx-editor.dev/react';
import { explainDiagnostic, type EditorDiagnostic, type EditorModule } from '@docx-editor.dev/core';

// Create the module once, outside the component. The editor reads modules only at creation.
const diagnostics: EditorModule = {
  id: 'diagnostics',
  onDiagnostic: (event: EditorDiagnostic) => {
    if (event.kind === 'edit.rejected') {
      console.warn(event.code, explainDiagnostic(event.code).hint);
    }
  },
};

const MODULES = [diagnostics];

export function Editor({ bytes }: { bytes: Uint8Array }) {
  return <DocxEditor document={bytes} modules={MODULES} />;
}

The module receives events from the initial document open. editor.on('diagnostic', listener) receives the same events, but only after the editor exists, so it misses the initial open. A listener that throws does not affect the editor.

Handle a failure code

Branch on code in application logic. These helpers from @docx-editor.dev/core map codes to text:

FunctionReturns
explainDiagnostic(code)The fixed hint for a code, and a docs link to its row on this page.
diagnosticCodeOfRefusal(reason)The code for the local refusal message in snapshot().lastRejection.
diagnosticCodes()Every public code.
diagnosticCauses()Every internal cause value.

In the editing API, a refusal has two codes. error.code says how the call failed. error.debugInfo.innerError.code names the rule from this page. Handle the inner code:

import { isDocxEditorError } from '@docx-editor.dev/editor-api';

try {
  await runtime.run(async (context) => {
    context.document.body.paragraphs.getFirst().insertText('Reviewed', 'End');
    await context.sync();
  });
} catch (error) {
  if (!isDocxEditorError(error)) throw error;
  const rule = error.debugInfo.innerError?.code;
  if (rule === 'edit.read-after-commit') {
    // The writes are applied. Read again; do not replay them.
  } else if (rule === 'edit.stale-target') {
    // Read the document again and reconsider the edit.
  } else {
    throw error;
  }
}

The outer code for one rule depends on when the runtime refused:

Outer error.codeWhen
InvalidArgumentThe runtime refused before it wrote anything, such as an unsupported field type or a protected insertion point. A string that is not well-formed XML also gives edit.invalid-argument.
GeneralExceptionThe document refused the write itself, such as a tracked write into content-locked content with edit.protected-content.
NotSupported, NotImplementedThe input or operation is outside the supported subset, such as insertOoxml() with more than one equation and edit.ooxml-unsupported.

Codes are stable. New codes can appear, but existing codes are never renamed. A tracking refusal never justifies switching tracking off automatically to make the edit succeed.

Read diagnostic events

Switch on kind to narrow the event. Every event also has schemaVersion, editorSessionId, and time. The editorSessionId is random per editor instance and is not persisted.

KindWhenFields
document.openA document opened or failed to open.outcome (opened or rejected), sizeBucket. Opened: durationMs, pagesBucket (omitted by headless hosts), and shape buckets. Rejected: code and the failure detail.
document.saveA save() call returned or failed.outcome (saved or rejected), durationMs. Saved: sizeBucket. Rejected: code and the failure detail.
edit.rejectedAn edit, command, or tracked change was refused.code, origin (command, input, or automation), tracked, command for a refused exec call, and the failure detail.
review.skippedA decision on tracked changes, such as Accept All, skipped some changes. A refused card reports edit.rejected first. In the editing API, only a refused batch reports it (count 1); resolve() returns its skips.code, count, and the failure detail.
font.failedA font did not load; a substitute applies.code.
historyAn undo step did not group as intended. Informational.code.
custom-nodeA custom node payload could not be read.code. The node name is not included.
collab.statusA collaboration session joined, disconnected, failed, or healed.status, previous, recovering, and code when something is wrong. The first ready has connectMs when the editor observed the wait.
collab.participantsThe number of people in the room changed.count, including this editor.
performanceA timing summary after a minute, on page hide, or on close.windowMs, optional pagesBucket, interaction, layout, and paint. Slow interactions add code. See Measure performance.
sessionAn editor started, was used, or ended.phase (start, active, or end). active and end add durationMs, activeMs, inputEdits, commandEdits, and automationEdits. See Measure sessions, edits, and saves.

Sizes and counts use buckets, such as 4-8MiB or 10-99.

Failure detail

Optional detail fields identify the engine condition and where it occurred. They use closed lists.

FieldOnHolds
causedocument.open, document.save, edit.rejected, review.skippedThe engine's own reason, such as undeclared-prefix under open.xml-malformed. For an unexpected error, exception.
errorNamedocument.open, document.save, edit.rejectedThe exception class when cause is exception, such as TypeError. The message is never included.
stagedocument.open, document.save, edit.rejectedWhere an exception was caught: open-mount, open-layout, command, review-item, automation, or save.
partdocument.open, review.skippedThe package part role, such as main-document, header, or relationships. Nonstandard names report other.
operationreview.skippedaccept, reject, or reassign.
changeKindreview.skippedinsert, delete, replace, moveFrom, moveTo, format, paragraphMark, or structural.
formattingKindreview.skippedThe property change, such as rPrChange or tblGridChange, or other.

Use code for application logic. Use cause only to investigate, because causes can change between versions.

An open that throws reports open.failed, a save that throws reports save.failed, and a command, review card, or editing API batch that throws reports edit.internal-invariant. Each has cause: 'exception', and the error still reaches your code. An exception from your own code inside run() is not reported.

This event shows a malformed header:

{
  "kind": "document.open",
  "outcome": "rejected",
  "code": "open.xml-malformed",
  "cause": "undeclared-prefix",
  "part": "header",
  "sizeBucket": "64-128KiB"
}

When you report a problem, include the code, the failure detail, and the engineVersion that your telemetry adds.

Codes

explainDiagnostic(code).docs links to each code's anchor, such as #edit-read-only.

Open

Limits marked server accept a higher value for a trusted file through the limits option of createServer. The other limits are fixed security refusals.

CodeCauseAction
open.unsupported-sourceThe input is not DOCX bytes.Pass a Uint8Array or ArrayBuffer of a .docx file, or 'blank'.
open.zip-corruptNot a valid ZIP archive, or an entry is damaged.Ask for a fresh copy.
open.zip-invalid-entry-nameAn entry path is unsafe, such as .. or a leading /.Refused for safety.
open.zip-entry-limitToo many archive entries.Server: limits.zip.maxEntries.
open.zip-size-limitThe archive expands past the total size limit.Server: limits.zip.maxTotalBytes.
open.zip-ratio-limitThe expansion ratio looks like a decompression bomb.Server: limits.zip.maxRatio.
open.xml-malformedAn XML part is not well formed.Open and save the file in a desktop editor to repair it.
open.xml-dtd-forbiddenAn XML part declares a DTD or entity.Refused to block XML entity attacks.
open.xml-part-size-limitOne XML part exceeds the per-part size limit.Server: limits.xml.maxBytes.
open.xml-depth-limitAn XML part nests too deep, often through nested tables.Fixed limit. Flatten the nesting.
open.xml-element-limitAn XML part has too many elements.Server: limits.xml.maxElements.
open.invalid-limitsThe createServer limits are not valid numbers.Check the limits option.
open.content-types-invalidNo valid [Content_Types].xml part.Save the file again as .docx.
open.missing-main-documentNo main document part, such as a renamed .xlsx or .pptx.Use a .docx file.
open.relationships-invalidA relationship is invalid or duplicated.Open and save the file in a desktop editor to repair it.
open.relationship-limitToo many relationships.Server: limits.maxRelationships.
open.part-limitToo many XML parts.Server: limits.maxXmlParts.
open.failedNo specific code applies.Report it with the engine version.

Save

CodeCauseAction
save.no-documentsave() ran before a document loaded, or after it failed to open.Wait for the open, and check document.open for a refusal.
save.document-changedA new document loaded while save() waited for a pending edit.Save again after the new document opens.
save.failedsave() threw. errorName and stage name the error class.Report it with the editor version.

Edit

CodeCauseAction
edit.read-onlyThe document is in viewing mode or protected as read-only.Change the mode, or remove the protection.
edit.protected-contentDocument protection or a locked content control blocks the edit.None.
edit.suggesting-needs-authorSuggesting needs an author.Pass the author option or call setAuthor.
edit.review-module-requiredThe operation needs the review module.Register reviewModule() from @docx-editor.dev/pro.
edit.tracked-drawing-delete-unsupportedThis operation cannot track a drawing deletion.Leave it, or ask a person to delete it in the editor.
edit.tracked-structure-unsupportedA structural edit cannot be tracked.Edit the text inside, or have a person edit with tracking off.
edit.tracked-operation-unsupportedAn editing API operation cannot be tracked. Nothing was applied.Use range.insertText or range.delete. Never switch tracking off to make it succeed.
edit.tracking-mode-unsupportedTrackAll needs every collaborator to enforce tracking.Use TrackMineOnly.
edit.tracking-author-requiredTrackMineOnly needs an author. The editor's author does not apply to a batch.Pass author to createServer or createBrowser.
edit.comment-author-requiredAn editing API comment or reply needs an author.Pass author to the runtime, or use useReview().comment or useReview().reply.
edit.comment-author-mismatchThe configured author does not own this comment or reply.Edit a comment that belongs to the current author. Author names are host metadata, not authentication.
edit.tracking-unsupported-hostThis automation host does not track changes.Use createServer or a mounted editor; both support TrackMineOnly.
edit.revision-unsupportedThe edit, accept, or reject touches an unsupported tracked change kind.Edit around it; leave it for a person.
edit.tracking-requiredProtection allows only tracked edits.Switch to suggesting, or set document.changeTrackingMode to TrackMineOnly.
edit.tracked-image-replace-unsupportedA picture replacement cannot be tracked.Insert the new picture as a tracked insertion.
edit.tracked-deleted-text-onlyThe tracked range holds only deleted text.Include live text, or insert next to the deleted text.
edit.tracked-foreign-revision-unsupportedThe edit touches another author's mark, formatting, move, or structural change, or a link or control in their insertion.Edit outside it. Accept All or Reject All clears a no-op formatting change.
edit.tracked-own-pending-changeThe edit covers or borders your own pending change.Read it with getReviewedText('Current'), then edit outside it, or reject and propose again.
edit.picture-selectedA picture is selected, so the new picture has no place.Place the caret in text, then insert.
edit.cross-structure-joinThe edit joins paragraphs in different containers, such as two cells.Edit each container separately.
edit.indivisible-contentThe edit splits an equation or field, or breaks inside an inline content control.Select the whole item, or edit outside the control.
edit.field-structureThe edit breaks a field's structure.Edit the whole result, or remove the whole field.
edit.field-unsupportedThe API does not write this field. Fields that fetch, embed, link, run, or prompt always refuse. Instructions never run.Use Page, NumPages, Ref, PageRef, NoteRef, Seq, StyleRef, Date, Time, or TOC.
edit.field-result-unsupportedA field result supports only reads and insertText(text, 'Replace') with plain text over plain runs.Use only those members.
edit.ooxml-unsupportedinsertOoxml takes only a Flat OPC package with one paragraph of plain runs around one inline m:oMath.Send only that shape.
edit.style-not-definedThe style is undefined, or is the wrong type.Assign a nameLocal from document.getStyles() of the right type.
edit.no-styles-definedThe document has no styles part.Leave the style, or use a document that defines it.
edit.section-markThe edit removes a section break with page settings.Remove the section break on its own.
edit.table-structure-unsupportedThe table shape is unsupported, such as a legacy horizontal merge or cells off the grid.Edit that row or table directly.
edit.table-merge-not-rectangleThe cells do not form a rectangle of two or more cells.Name the top-left and bottom-right cells of a clean rectangle.
edit.table-split-unsupportedThe cell cannot split into these counts.Use row counts that divide merged rows, and keep the minimum column width. Without a column grid, use a column count that divides the cell's column span.
edit.table-insert-refusedA table cannot go at the selection, such as inside a field.Move the caret.
edit.table-of-contents-refusedThe table of contents cannot be inserted or updated here.Place the selection in the main body.
edit.unsupported-contentThe edit touches content the editor shows but cannot change.The content is kept as is.
edit.operation-unsupportedThe operation or option is unsupported by this runtime or host.Check the member's compatibility notes.
edit.unsupported-storyThis header, footer, or note does not support the edit.None.
edit.unmapped-changeA browser change could not map to a document edit.None. The editor undid the change.
edit.stale-targetThe target no longer exists, often after a remote or undone change. The API pairs it with InvalidObjectPath.Read again and reconsider before you retry.
edit.invalid-argumentAn argument is not valid for this target.Check each argument against the member.
edit.resource-limitThe edit exceeds a size or nesting limit.Split it into smaller edits.
edit.refresh-in-progressA document refresh is running.Retry after it completes.
edit.preview-activeA preview is open, so writes and a second preview are refused.Commit or discard the preview.
edit.preview-unsupportedA preview cannot show this operation.Write it with run() after the preview.
edit.preview-composingAn input method composition is in progress.Retry after it ends.
edit.preview-divergedA replayed read differs from the preview, so the commit wrote nothing.Read again and build a new preview.
edit.read-after-commitThe writes are applied, and a load after them failed.Read again. Do not apply the same edit again.
edit.collaboration-not-readyThe collaboration session is not ready.Wait for ready; rejoin a destroyed session.
edit.collaboration-text-limitOne edit inserted too much text.Insert in smaller parts.
edit.internal-invariantThe editor refused to protect document structure. This is an engine defect.Report it with the engine version. Do not retry unchanged.
edit.refusedNo specific code applies.Read snapshot().lastRejection.

Review

CodeCauseAction
review.revision-unsupportedThe change kind cannot be accepted or rejected, so it stays. A change with no w:id or author has cause unaddressed.Keep it, or edit directly with tracking off.
review.incomplete-groupThe decision would also resolve a change it leaves out. The cause names it, such as paired-change.Clear the filter, decide that change first, or decide both.
review.retained-structureThe row holds an untracked nested table (cause nested-table).Use resolve() or Accept All; acceptAll() and rejectAll() refuse whole.
review.locked-contentA content control locks the content.Set ContentControl.cannotEdit to false, then decide.
review.bound-contentThe control is bound to a custom XML part.Keep the change. The decision stays blocked while the binding exists, so remove the binding outside the editor first.
review.stale-revisionThe change no longer exists.Read the review items again.

Font

The editor substitutes a font for each of these codes.

CodeCauseAction
font.shaper-unavailableThe text shaper did not load; fallback metrics apply.Serve the HarfBuzz WebAssembly file from your bundler.
font.load-failedA font face did not load.Check the source URL and its CORS headers.
font.missingA requested font is not available.Add the face to the fonts option.
font.integrity-mismatchA face does not match its declared hash or metadata.None.
font.malformedA file is not a valid font.Check the file the source points at.
font.size-limitA file exceeds the font byte budget.Subset it, or serve a smaller face.
font.unsupported-faceUnsupported format or face index.None.

History

CodeCauseAction
history.splitAn edit started a new undo step inside one gesture.Wrap the gesture in beginHistoryGroup.
history.possible-ungrouped-gestureQuick commands ran without a history group.Use beginHistoryGroup for one gesture.
history.possible-fragmented-gestureOne gesture spans several history groups.Keep one group open for the gesture.

Custom nodes

CodeCauseAction
custom-node.payload-invalidA payload does not match the node schema; the node opened without data.Check the schema version that wrote the file.
custom-node.payload-missingA node points at a missing payload, often after a partial export or a manual edit.None. The node opened without its data.

Performance

CodeCauseAction
performance.slow-interactionMore than 1 in 20 key presses or clicks took over 200 ms to paint.Compare layout (follows document size) and paint (follows pages on screen).

Collaboration

A collaboration code is collab. plus the session's failure code, on collab.status events. An edit that a session refuses reports edit.rejected with an edit.collaboration-* code instead.

CodesAction
collab.collaboration-session-destroyed, collab.collaboration-session-not-attached, collab.collaboration-session-not-readyThe session could not take work. Wait for ready, or rejoin a destroyed session.
collab.collaboration-text-limitOne edit inserted too much text. Insert in smaller parts.
collab.experimental-collaboration-body-text-onlyA review write (a comment or revision change) declared no intent the session replicates. Use the built-in comment and revision commands.
collab.invalid-document-id, collab.invalid-identity, collab.invalid-identity-color, collab.invalid-session-idThe factory rejected a host value before joining. Fix the document ID, session ID, or identity.
collab.already-initialized, collab.document-id-mismatch, collab.initialization-aborted, collab.not-initializedThe join did not complete. Check the provider connection and room ID, then rejoin.
collab.initialization-timeoutThe join timed out. Check that the server is reachable, then rejoin.
collab.baseline-too-large, collab.blob-read, collab.invalid-baseline, collab.missing-local-blob, collab.no-main-document-partThe document cannot seed a room. Open the file alone to find the problem, or seed from another copy.
collab.collaboration-format-mismatch, collab.protocol-version-mismatch, collab.schema-version-mismatchClient and room formats differ. Save local work, then upgrade the client or migrate the room.
collab.blob-digest-mismatch, collab.concurrent-seed, collab.port-already-attachedThe room is unusable. Save a copy, then create a room from saved bytes.
collab.duplicate-paragraph-id, collab.invalid-relationships, collab.materialize-dropped-content, collab.missing-blob, collab.missing-root, collab.remote-apply-failed, collab.unknown-paragraph-idA remote update did not apply. Edits pause until a later update repairs the session. Investigate if it persists.
collab.blob-store-full, collab.blob-too-large, collab.text-too-long, collab.too-many-attributes, collab.too-many-children, collab.too-many-nodes, collab.too-many-parts, collab.too-many-relationships, collab.tree-too-deepShared state reached a resource limit. The session reverses refused local edits. If the room exceeds a limit, recreate it from a saved copy.
collab.invalid-blob-descriptor, collab.invalid-bound, collab.invalid-logical-id, collab.unknown-logical-idShared state holds a malformed value or missing reference. The session reverses refused local edits. If the room holds it, recreate the room from a saved copy.
collab.invalid-string, collab.prototype-key, collab.unsafe-part-nameA peer sent malformed state: invalid XML text, a key that reaches object internals, or an unsafe part name. Save a copy and recreate the room.
collab.invalid-saved-room, collab.saved-room-unavailableThe room server refused the saved room. Check server storage, then rejoin.
collab.authentication-failedThe server refused the credential. Refresh the token, then rejoin; the same token fails again.
collab.room-generation-changedThe server compacted the room while this client was away. Save unsent changes, then rejoin.
collab.transportThe transport failed. Check the network and server, then rejoin.
collab.transport-disconnectedThe connection dropped. The session reconnects on its own; edits continue offline when offline editing is on.
collab.baseline-digest-mismatch, collab.experimental-collaboration-existing-paragraphs-only, collab.experimental-collaboration-text-only, collab.experimental-collaboration-untracked-text-only, collab.immutable-baseline-changed, collab.immutable-metadata-changed, collab.invalid-shared-metadata, collab.local-mirror-failed, collab.paragraph-set-mismatch, collab.shared-schema-invalid, collab.unsupported-root-keyNo longer emitted. Upgrade the packages on every client and server.

Protect diagnostic data

Engine diagnostics never contain document content. They use closed lists of codes, booleans, and bucketed numbers. Document text, part names, relationship targets, author names, font names, and exception messages are excluded.

Attributes that you add, raw errors, and data your SDK collects can still disclose content. Rare bucket combinations can also distinguish documents within an organization. For more information, see Privacy review checklist.

See also