You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File:packages/pluggableWidgets/document-viewer-web/src/components/DocxViewer.tsx line 17–33
Note: The loadContent callback awaits renderAsync and catches all errors via a shared catch block. But it doesn't check whether the abort signal has fired before calling setDocumentStatus. If the effect cleanup runs (controller aborts) while renderAsync is still in flight, and then renderAsync throws/rejects due to the abort, the error handler will still call setDocumentStatus — causing a state update on an unmounted/re-rendered component. Compare with the outer fetch.catch, which correctly guards with if (!signal.aborted). The loadContent function should receive or close over the signal and apply the same guard.
Fix:
constloadContent=useCallback(async(arrayBuffer: any,signal: AbortSignal)=>{try{if(localRef.current){conststyleContainer=document.createElement("div");awaitrenderAsync(arrayBuffer,localRef.current,styleContainer,DOC_CONFIG);}}catch(_error: any){if(!signal.aborted){setDocumentStatus({status: DocumentStatus.error,message: "Failed to load DOCX document"});}}},[setDocumentStatus]);// then pass signal through: .then(response => loadContent(response, signal))
⚠️ Low — pdfjs-dist version constraint changed from pinned to range
File:packages/pluggableWidgets/document-viewer-web/package.json line 50
Note:pdfjs-dist was previously pinned at an exact version (4.8.69); it's now a range (^6.1.200). PDF.js is notoriously sensitive to minor version changes (worker/API compatibility, CMaps paths). Pinning or at least using a tighter range (e.g. ~6.1.200) would make future lockfile regenerations more predictable and reduce the risk of a silent breakage when a patch lands.
Positives
The refactor from the two-step parseAsync+renderDocument to the single renderAsync call is cleaner and matches the current docx-preview 0.4.x public API correctly.
Adding .catch on the fetch chain (with signal.aborted guard) properly prevents spurious error states on cleanup — good defensive pattern.
CHANGELOG entry is present and follows Keep a Changelog format.
The styleContainer side-channel trick to prevent library styles from leaking into document.head is preserved and now carries an explanatory comment.
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
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.
Pull request type
Description