-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
When you render a PDF in node the actual error gets logged to console.error and a different error gets thrown TypeError: Cannot read properties of null. This has two issues:
- When logging errors to Sentry you always get the same error.
- When using a formatted logger the console.error pollutes the stdout/stderror with non-formated logs.
When debugging I learned, but rethrowing the error instead of logging it here it worked as expected:
react-pdf/packages/reconciler/src/reconciler-31.ts
Lines 68 to 70 in 4aad0f9
| logRecoverableError, // onUncaughtError | |
| logRecoverableError, // onCaughtError | |
| logRecoverableError, // onRecoverableError |
I have two suggestions and would be happy to open PRs in case there is interest for them:
- instead of console.log/warn/error allow to pass in a logger that by default is console
- instead of logging the reconciler errors they are re-thrown
To Reproduce
Steps to reproduce the behavior including code snippet (if applies):
Add this code in a component:
Example in a component:
if ('test' in {}.test2) {
console.log('Did not fail');
}and render the PDF in node e.g. https://github.com/diegomura/react-pdf/blob/master/e2e/node-esm/index.js
You can make use of react-pdf REPL to share the snippet
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOS
- Node
- React-pdf version
"@react-pdf/renderer": "^4.3.0"