Fix error handling and logging
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- node.js, react, typescript
- Domain
- backend
Research direction
Start with packages/reconciler/src/reconciler-31.ts at the linked error-handling code, then reproduce the failure using the component snippet and e2e/node-esm/index.js. Confirm that the original rendering error is surfaced rather than replaced, and that it is not emitted through an unformatted console call.
Written by the indexing model from the issue text.
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:
https://github.com/diegomura/react-pdf/blob/4aad0f971a484b75c3ff8de6729de15bc6ffe587/packages/reconciler/src/reconciler-31.ts#L68-L70
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"
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.3k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diegomura/react-pdf
-
@react-pdf/font: published types import fontkit, but @types/fontkit is only a devDependencyPossibly taken @iliev-blnk claimed this 16 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Unable to set flexShrink to 0Possibly taken @adarshsm claimed this 15 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
@react-pdf/hyphenate: import-only exports map throws ERR_PACKAGE_PATH_NOT_EXPORTED in require-condition resolvers (every tsx script loading renderer >= 4.7 crashes)Possibly taken @cruzdanilo claimed this 44 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
diegomura/react-pdf#3551 · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
All issues in diegomura/react-pdf
Similar issues
-
twilio.webhook() rejects valid requests when the query string has an encoded `?` and a `+` spaceOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
twilio/twilio-node#1232 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Tiling managers are not destroyed in disable(), so window-created handlers keep running (Gio.Settings constructed without schema)Possibly taken @gnacho claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
domferr/tilingshell#641 ·
Maintainers usually reply within 3 days
-
🐛 bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
LibreChat-AI/LibreChat#17887 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100