question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can we not break the Viewer if source is sent twice in a fraction of second ? Observed Error: Worker was terminated

See original GitHub issue

Error in console and PDF viewer is blank: The error says “worker was terminated” and also another error says “You’re trying to open two instances of the PDF viewer. Most likely, this will result in errors.”

Possible questions: Is there any event or property or callback you exposed saying that instance is already running. i tried looking into the NgxExtendedPdfViewerService but no luck to see if the instance is already running or not ? Please suggest a way how to identify if a instance is already running ? or is there a way in code where i can end or destroy the current instance that is up and then accept the 2nd instance to be the 1st or vice versa ?

Problem statement: How do i know if a instance is already running ? or is it possible if a second instance is initialized the first instance should terminate or untill the first instance is ended the second instance cannot be opened. Today if second instance is up then the page breaks 😦 Can we not consider the second instance at all? Can this enhancement suggestion be considered ? I dont want my PDF viewer to break at all. Please suggest ?

Error in console: image

Seeing this blank window with scroll bar: image

Code:

<ng-container *ngIf="useCustomRendered">
<!-- Default: Renders the PDF using the custom viewer  -->
<ngx-extended-pdf-viewer [src]="safeUrl" height="100vh" zoom="115%" [useBrowserLocale]="true"
[showBorders]="false" backgroundColor="white" [showSidebarButton]="false" [showFindButton]="false"
[showPagingButtons]="false" [showZoomButtons]="false" [showPresentationModeButton]="false"
[showOpenFileButton]="false" [showPrintButton]="false" [showDownloadButton]="false"
[filenameForDownload]="false" [showBookmarkButton]="false" [showSecondaryToolbarButton]="false"
[showRotateButton]="false" [showHandToolButton]="false" [showScrollingButton]="false" [showSpreadButton]="false"
[showPropertiesButton]="false">
</ngx-extended-pdf-viewer>
</ng-container>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stephanrauhcommented, Oct 1, 2020

I’ve played around one or two hours with your scenario. I think I know what’s going on. However, I believe that stopping a render task is difficult. For most users, there’s only the occasional error message “Worker was terminated”, but the PDF file shows without problems. So I’d prefer not to change anything.

However, I suppose it’s easy on your side. I’ve already mentioned the double-click protection. But you also know which data the user requests, and you’ve got the BLOB data. So it should be easy to detect if the user sends identical data to the PDF viewer twice.

Hope that helps! Stephan

1reaction
stephanrauhcommented, Oct 1, 2020

In any case, I’d add a double-click protection to the button. Almost every user has learned that a double click always does the trick on Windows. They don’t distinguish between desktop applications and web applications, so they use their trick in the web, too. Most of the time it works perfectly: double-clicking on a link does exactly what you want, unless your technically versed and watch the network traffic.

Here are several nice approaches: https://stackoverflow.com/questions/51390476/how-to-prevent-double-click-in-angular

IMHO using RXJS debounce() is the most elegant approach, but disabling the button after is has been clicked is even simpler.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Reporting and Disclosure - Patient Safety and Quality
If providers cover up errors and mistakes, they do not necessarily stay hidden and often result in compromising the mission of health care...
Read more >
Grade 7 Answer Key - Louisiana Believes
What fraction of a scarf can Amelia knit in 1 hour? ... explain whether or not it must indicate that the points in...
Read more >
Mathematics 1 Problem Sets - Phillips Exeter Academy
The way the math books are setup. (i.e. simple problems progressing to harder ones on a concept) really helps me understand the mathematical ......
Read more >
OSHA Technical Manual (OTM) - Section III: Chapter 5
An important consideration might be how close workers will be working to the source of sound. As a general rule, doubling the sound...
Read more >
4 Math: Problem-Solving in Functions and Algebra - CUNY
n Math has nothing to do with communication, creativity or intuition. n There is one right way to solve a math problem—so if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found