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

renderToPipeableStream: Expose errors through onError, no longer emit un-catchable error event on internal stream #405

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

f0x52
Copy link

@f0x52 f0x52 commented Jan 4, 2025

Fixes #404

Changes error and abort handling in renderToPipeableStream so the stream no longer emits an uncatchable error event. Instead errors are passed to options.onError if provided. If there is no error callback it's rethrown, though maybe that's not ideal since it happens in the async chain, so can't really be caught either. Alternatively this could just console.error, so it doesn't get silently swallowed entirely?

Also added an optional reason argument for stream.abort(), defaulting to new Error(The render was aborted by the server without a reason.) inspired by React. Previously this was just new Error('aborted'), though this was never exposed to consumers.
Abort still destroys the stream, and also calls the onError callback (if defined) with the reason

… un-catchable error event on internal stream
Copy link

changeset-bot bot commented Jan 4, 2025

🦋 Changeset detected

Latest commit: 310e1bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Successfully merging this pull request may close these issues.

Errors in renderToPipeableStream crash Node.js process
1 participant