This commit introduces several improvements to the rendering functions to enhance type safety, error handling, and resource management. The changes include:
Type Safety: Ensured that the lazyHtml function is correctly typed to return a Promise<JSX.Element>.
Error Handling: Added try-catch blocks to handle errors more gracefully and provide meaningful error messages in both renderToString and renderToStringResponse functions.
Resource Management: Implemented a cancel method in the ReadableStream to handle stream cancellation properly.
Concurrency Control: Managed the stream controller more effectively, ensuring that errors are handled within the promise chain in the renderToStream function.
Validation: Added basic validation and error messages to ensure that the functions behave as expected.
These changes make the code more robust, safer, and easier to maintain, improving the overall reliability of the rendering process.
Description:
This commit introduces several improvements to the rendering functions to enhance type safety, error handling, and resource management. The changes include:
lazyHtml
function is correctly typed to return aPromise<JSX.Element>
.renderToString
andrenderToStringResponse
functions.cancel
method in theReadableStream
to handle stream cancellation properly.renderToStream
function.These changes make the code more robust, safer, and easier to maintain, improving the overall reliability of the rendering process.