Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataCloneError: Failed to execute 'postMessage' on 'Worker' #9840

Closed
MateEke opened this issue Jun 25, 2018 · 11 comments
Closed

DataCloneError: Failed to execute 'postMessage' on 'Worker' #9840

MateEke opened this issue Jun 25, 2018 · 11 comments

Comments

@MateEke
Copy link

MateEke commented Jun 25, 2018

Attach (recommended) or Link to PDF file here:

Configuration:

  • Web browser and its version: Electron 2.0.3
  • Operating system and its version: Windows 10
  • PDF.js version: 2.0.489
  • Is a browser extension: no

Steps to reproduce the problem:
Create Ellectron app with angular 6 + pdfjs

What is the expected behavior? (add screenshot)
PDF gets displayed

What went wrong? (add screenshot)

ERROR Error: Uncaught (in promise): DataCloneError: Failed to execute 'postMessage' on 'Worker': TypeError: https.request is not a function could not be cloned.
Error: Failed to execute 'postMessage' on 'Worker': TypeError: https.request is not a function could not be cloned.

In Google Chrome everything works fine.

VadimDez/ng2-pdf-viewer#326

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Jun 25, 2018

app with angular 6

This looks like a duplicate of issue #9166, which was caused by a bug in Angular (rather than PDF.js); please refer to angular/zone.js#980.

@MateEke
Copy link
Author

MateEke commented Jun 25, 2018

This issue is related to non-existent PDF - I have an existing PDF, and the error only occurs in electron app. In Google Chrome everything works fine in my case.

@timvandermeij
Copy link
Contributor

I don't think we can do anything on the PDF.js side without more information, most notably a running demo that shows the issue. Moreover, make sure zone.js is updated per the issue above.

@timvandermeij
Copy link
Contributor

Closing since no information shows that this is caused by PDF.js itself. All signs point to the Angular issue mentioned above, and there have been more reports of it there.

@giridharkannan
Copy link

The issue is not what the error message says, it's actually something else. Since error handling faced another exception while reporting, things got messed up.

The reason for the issue is, Http module misses "require" method to be precise both Http and Https modules are empty.

When using pdf.js in Chrome browser, it uses PDFFetchStream to read data whereas when using pdf.js in Electron it uses PDFNodeStream. When in Electron, to resolve Http request PDFNodeStream uses Node's Http module ( require('http') ), somehow the http variable got overwritten.

Moving Http import inside PDFNodeStreamFullReader and PDFNodeStreamRangeReader solves the issue that we face.

I don't know why http variable got overwritten or who is responsible for this issue as am very new to frontend development but it would be helpful if someone helps us out to resolve this problem.

@Farbod29
Copy link

Farbod29 commented Apr 6, 2019

@giridharkannan I have same issue but I don't know how to move Http report to both PDFNodeStreamFullReader and PDFNodeStreamRangeReader.

@giridharkannan
Copy link

@Farbod29
It's been long and I forgot the context, but I can share my working code snippet. Hope this will be helpful

       if(isElectronBuild()) {
            pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
                return new PDFFetchStream(params);
            });
            task = getDocument(pdfUrl);
        } else {
            task = getDocument(pdfUrl);
        }
`

@Farbod29
Copy link

Farbod29 commented Apr 6, 2019

Screenshot 2019-04-06 21 26 46

@Farbod29
Copy link

Farbod29 commented Apr 6, 2019

@giridharkannan thanks for prompt response,I just added task = getDocument(pdfUrl); here but I don't really know how PDF.js working didn't fix yet.

Screenshot 2019-04-06 21 31 31

@Farbod29
Copy link

Farbod29 commented Apr 6, 2019

Screenshot 2019-04-06 21 37 31
Screenshot 2019-04-06 21 37 55
Screenshot 2019-04-06 21 31 31
Screenshot 2019-04-06 18 45 59
Screenshot 2019-04-06 21 25 04
Screenshot 2019-04-06 18 42 36

@giridharkannan
Copy link

@Farbod29 If it's not a overkill, please do share your code snippet to my mail id. And the code snippet that I gave is not be added on pdf.js's code base, rather on your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants