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.

sendWithPromise("GetPage", ... null causing an error

See original GitHub issue

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

I use two instances of react-pdf. The main viewer is using a functional component and the second one is a class-based that’s not visible. It’s a background renderer to produce pdf thumbnail previews. This has been working fine since 2021.

After recently pulling down 5.7.2 my background PDF render throws an error just before it renders. After reverting to 5.7.1 it’s working fine.

  • load 1 PDF it’s fine
  • load another PDF it breaks

I put error handlers on the <Document... and <Page... I have onSourceError, onLoadError, onRendeError handlers but those don’t fire, the error above happens.

I will continue investigating/work on reproducible code unfortunately what I’m working on is not public.

Attached below are the images of the error.

Steps to reproduce

Setup a class-based react-pdf component.

Pass down a file path (by props), it renders.

Pass down another file path

Expected behavior

The PDFs render as the sources are updated.

Actual behavior

Fails to render the PDF/produces the errors below

When this error happens it crashes the entire react app eg. blank screen.

err-1

err-2

Additional information

No response

Environment

  • Browser (if applicable): Chrome
  • React-PDF version: 5.7.2
  • React version: ^4.42.0
  • Webpack version (if applicable): ^16.3.0

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
PerryAJcommented, Jul 19, 2022

We’ve hit the same situation with an application using react 16.14. The first PDF seemed to load fine, but remounting or changing to a new PDF would result in errors.

Was able to workaround by rolling back to 5.7.1 as others have. Don’t have much else to add to previous reports, but did want to note that the root cause was one of a number of different errors on different subcomponents from Page down. For future search-ability, figured it was worth adding examples from a dev bundle created with 5.7.2:

Failed prop type: The prop 'page.commonObjs._objs' is marked as required in 'PageCanvasInternal', but its value is 'undefined'. 

Failed prop type: The prop 'page.commonObjs._objs' is marked as required in 'TextLayerInternal', but its value is 'undefined'
1reaction
illusdolphincommented, Dec 8, 2022

We have this issue for the following flow:

  1. Render without file (see No PDF file specified.)
  2. File is selected => ok
  3. Render without file (see No PDF file specified.)
  4. File is selected again => JS error Downgrade to 5.7.1 didn’t help, was another issue. Made a workaround: just to add Key for Document component that contains file name, then everything seems to work fine because of re-initialization of component. 6.x branch is not usable due to issue #1043 (thanks for keeping API compatible, but webpack 4 seems to be not compatible anymore without some re-configuration)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught (in promise) TypeError: Cannot read properties of ...
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'sendWithPromise') at WorkerTransport.getPage (api.js:2792:21) at ...
Read more >
JSDoc: Source: api.js
"object") {; throw new Error(; "Invalid parameter in getDocument, " +; "need either string ... sendWithPromise("Terminate", null);; waitOn.push(terminated); ...
Read more >
JSDoc: Source: display/api.js
"object") {; throw new Error(; "Invalid parameter in getDocument, " + ... _worker = null;; /**; * Unique document loading task id --...
Read more >
Cannot read property 'sendWithPromise' of null error
Cannot read property 'sendWithPromise' of null error. ng2-pdf-viewer. 18 September 2018 Posted by fncamm. Bug Report or ...
Read more >
PDF.js Worker - Source code - Greasy Fork
throw new Error('Worker was terminated'); } pdfManager = newPdfManager; pdfManager. ... getPage(pageIndex).then(function (page) { var task = new ...
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