Uncaught (in promise) ReferenceError: tc is not defined at ba.k6

Product: Webviewer Server

Product Version:
@pdftron/webviewer: 8.3.0-20211201
pdftron/webviewer-server:1.5.8

Please give a brief summary of your issue:
Our team just started using Webviewer Server to load documents and we have consistently been seeing the following error statements. These errors are not customer impacting and it seems like adding annotations and viewing documents are not affected but we would like to know the source of this issue to mitigate noise.

Please describe your issue and provide steps to reproduce it:
Here is a public Sentry link: Sentry

We cannot reproduce this consistently but this happens on a semi-regular occurence on our staging and production environments on documentload.

Error and Warning Statements:

ReferenceError: tc is not defined at ba.k6 
(webviewer/lib/core/WebViewerServerPartRetriever.chunk.js:19:229)/n at ca.l6 
(webviewer/lib/core/webviewer-core.min.js:2022:15)/n at ca.kba 
(webviewer/lib/core/webviewer-core.min.js:2037:435)/n at ca.getNewAppearanceDocument 
(webviewer/lib/core/webviewer-core.min.js:2038:472)/n at ca.bA 
(webviewer/lib/core/webviewer-core.min.js:2037:96)/n at ca.h.xm 
(webviewer/lib/core/webviewer-core.min.js:983:29)/n at ca.xm 
(webviewer/lib/core/webviewer-core.min.js:2044:125)/n at ba.xm 
(webviewer/lib/core/webviewer-core.min.js:235:64)/n at ba.xm 
(webviewer/lib/core/webviewer-core.min.js:369:32)/n at ba.j$ (webviewer/lib/core/webviewer-core.min.js:359:383)
Uncaught Error: ReferenceError: tc is not defined
ea	@	webviewer/lib/core/webviewer-core.min.js 193:243
        @	webviewer/lib/core/webviewer-core.min.js 574:376
Array.forEach	@	-1:-1
x.f.trigger	@	webviewer/lib/core/webviewer-core.min.js 574:283
HTMLDivElement.f	@	webviewer/lib/core/webviewer-core.min.js 1027:481
Annotation appearance failed to render: : WebViewerServerDocument does not support appearances
Uncaught (in promise) WebViewerServerDocument does not support appearances

Sample code for loadDocument and Initialization:
Initialization

const webViewer = useRef<WebViewer | undefined>();

    useEffect(() => {
        if (!viewerElement || undefined === usingWebViewerServer) {
            return;
        }

        const initialize = async () => {
            const identifier = v4();

            setLoading(true);

            const { default: WebViewer } = await import('@pdftron/webviewer');

            const instance = await WebViewer(
                {
                    path: '/webviewer/lib',
                    licenseKey: PDFTRON_LICENSE,
                    fullAPI: loadAsPDF,
                    loadAsPDF,
                    fallbackToClientSide: true,
                    webviewerServerURL: usingWebViewerServer
                        ? PDFTRON_WEBVIEWER_SERVER_URL
                        : undefined
                } as any,
                viewerElement
            );

            webViewer.current = { instance, identifier };

            setLoading(false);
        };

        initialize();

        return () => {
            try {
                webViewer.current?.instance.Core.documentViewer.dispose();
                webViewer.current?.instance.UI.dispose();
            } catch (error) {
                console.warn(error);
            }
        };
    }, [
        contextIdentifier,
        loadAsPDF,
        stopwatch,
        usingWebViewerServer,
        viewerElement
    ]);

Load Document

webViewer.instance.UI.loadDocument(documentMeta.source.url, {
    extension: documentMeta.extension,
    cacheKey: documentMeta.fileRevision.id
});

Apply Annotations

const importedAnnotations = await Promise.all(
    loadedAnnotations.map(async (loadedAnnotation) => {
        const importResult = (await annotationManager.importAnnotations(
            loadedAnnotation.xfdf
        )) as PDFTronAnnotation[];
        const importedAnnotation = importResult[0];
        if (!importedAnnotation) {
            return;
        }

        importedAnnotation.Author =
            loadedAnnotation.user.full_name || loadedAnnotation.user.email;
        importedAnnotation.Locked =
            loadedAnnotation.created_by_id !== getUserId();

        importedAnnotation.setCustomData(
            'annotationId',
            loadedAnnotation.id
        );

        return importedAnnotation;
    })
);

annotationManager.drawAnnotationsFromList(compact(importedAnnotations));

Hello davidlee,

Thank you for reporting this, I noticed you are using a build from 2021-12-01, and since then we have made a bugfix for a similar issue.

We are now on v8.3.2, there is no breaking changes between the version, you can find the download here: PDFTron or if you are using NPM you can do npm i @pdftron/webviewer@latest

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

1 Like

Thank you! We will try migrating to v8.3.2 and let you know if the issue persists!