Skip to content

loadingTask.destroy() throws worker exception #11595

@zmagyar

Description

@zmagyar

I'm displaying a progress bar on document loading with a Cancel button to give a chance to the user to abort the download. If I understood correctly based on #6546 calling destroy() on the loading task is the correct way to do it. But that throws an exception in the worker what I even not able to catch anywhere.

Configuration:

  • Web browser and its version: Chrome 80.0.3987, Safari 13.0.5 (15608.5.11)
  • Operating system and its version: MacOS 10.15.3
  • PDF.js version: v2.3.200 (same in 2.2.228)
  • Is a browser extension: no

Steps to reproduce the problem:

  1. Call loadingTask.destroy() before getDocument resolves

What is the expected behavior? (add screenshot)
Worker should stop without exception

What went wrong? (add screenshot)
Try https://jsfiddle.net/zmagyar/uLnqk1m5/1/#
Console says:
(index):76 Error: Worker was destroyed
at terminateEarly (api.js:1781)
at api.js:1827
at Worker.MessageHandler._onComObjOnMessage (message_handler.js:147)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions