Skip to content

navigator does not contain platform - require('pdfjs-dist') leads to error #116

@rajeshtezu

Description

@rajeshtezu

detectrtc when used with pdfjs-dist in node.js environment produces an error due to incomplete polyfill for navigator in the detectrtc.

Error

    isWin: navigator.platform.includes("Win"),
                                ^
    TypeError: Cannot read properties of undefined (reading 'includes')

Cause of error

In node.js environment we don't get navigator object - pdfjs-dist makes a decision based on the presence of navigator object i.e. if present it tries to access navigator.platform.<methods> which is reasonable.

When used with detectrtc it gets the navigator object (polyfill), as a result it goes and tries to access methods on platform property but since platform itself is unavailable, calling any method on top of it throws error.

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions