DocumentServer icon indicating copy to clipboard operation
DocumentServer copied to clipboard

Bug: TypeError: t is undefined on editor init when loading a PDF with JavaScript API v8.3.3

Open jekemino opened this issue 6 months ago • 1 comments

Hello ONLYOFFICE Team,

I am trying to integrate Document Server with a custom application (Paperless-ngx) to edit PDF files. I am using the JavaScript API to initialize the editor.

The editor UI begins to load, but it immediately crashes with an Uncaught TypeError: t is undefined from within sdk-all.js. The editor shows a popup with "An error occurred while opening the file."

This happens after we have successfully resolved all other issues (CORS, JWT validation, Basic Auth popups by using allowedOrigins).

My Environment:

  • ONLYOFFICE Docs Version: 8.3.3 (from editor URL: .../8.3.3-eae42720ea663f0a12aa4bf699b24bdb/...)
  • Installation Type: Official Docker image (onlyoffice/documentserver:latest)
  • Integration Method: A custom Python/Flask webhook generates a full HTML page that loads the editor via the JavaScript API.

Problem Description: The core issue seems to be an internal JavaScript error when new DocsAPI.DocEditor() is called with a specific configuration object. The configuration object points the document.url to a proxy endpoint on our webhook, which then securely fetches the document from the source application. This proxy endpoint has been tested with curl and it successfully serves the PDF file with the correct Content-Type: application/pdf header.

The error occurs deep inside the editor's sdk-all.js, which suggests the config object is missing a required parameter or has a subtle incompatibility with this version.

Steps to Reproduce: The issue can be reproduced by loading a simple HTML page that calls the DocEditor constructor with the exact config object generated by our webhook.

  1. HTML Loader Page:

    <!DOCTYPE html>
    <html lang="it">
        <head>
            <title>Editor Test</title>
        </head>
        <body>
            <div id="placeholder" style="width:100vw; height:100vh;"></div>
            <script type="text/javascript" src="[https://office.nequidnimis.com/web-apps/apps/api/documents/api.js](https://office.nequidnimis.com/web-apps/apps/api/documents/api.js)"></script>
            <script type="text/javascript">
                var docEditorConfig = { /* JSON object from below */ };
                new DocsAPI.DocEditor("placeholder", docEditorConfig);
            </script>
        </body>
    </html>
    
  2. docEditorConfig Object (this is the actual JSON that causes the error):

    {
        "document": {
            "fileType": "pdf",
            "key": "paperless_1_1750227460",
            "permissions": {
                "comment": true,
                "download": true,
                "edit": true,
                "print": true,
                "review": true
            },
            "title": "test.pdf",
            "url": "https://[IL_TUO_DOMINIO_WEBHOOK]/download_proxy/1"
        },
        "documentType": "word",
        "editorConfig": {
            "callbackUrl": "https://[IL_TUO_DOMINIO_WEBHOOK]/onlyoffice_callback",
            "customization": {
                "autosave": true,
                "forcesave": true
            },
            "lang": "it",
            "mode": "edit",
            "user": {
                "id": "user_id_1",
                "name": "User 1"
            }
        },
        "height": "100%",
        "token": "A_VALID_JWT_IS_GENERATED_HERE",
        "width": "100%"
    }
    

Console Error Log:

Uncaught TypeError: t is undefined dfg https://office.nequidnimis.com/8.3.3-eae42720ea663f0a12aa4bf699b24bdb/sdkjs/word/sdk-all.js:13370 Ysi https://office.nequidnimis.com/8.3.3-eae42720ea663f0a12aa4bf699b24bdb/sdkjs/word/sdk-all-min.js:1953 Pe https://office.nequidnimis.com/8.3.3-eae42720ea663f0a12aa4bf699b24bdb/sdkjs/word/sdk-all.js:13300

Question for the ONLYOFFICE Team: Could you please review the provided config object? Is there a missing, malformed, or deprecated parameter that would cause this internal TypeError in Document Server v8.3.3 when opening a PDF file this way?

We have already tried adding/removing several parameters (permissions, customization.customer, documentType, etc.) with no change in the result.

Thank you for your time and help.

jekemino avatar Jun 18 '25 12:06 jekemino

Hi @jekemino documenttype The documentation describes that for the PDF format, a separate parameter is set in the configuration that launches the PDF editor session

askonev avatar Jun 19 '25 13:06 askonev

This issue was closed due to no response.

Rita-Bubnova avatar Jul 28 '25 12:07 Rita-Bubnova