Skip to content

🎥 Make videos programmatically with React

@remotion/web-renderer: address PR review comments

Cursor Agent6457ded61c56
diff --git a/packages/web-renderer/src/create-scaffold.tsx b/packages/web-renderer/src/create-scaffold.tsx
index 01b5253391..31241e586d 100644
--- a/packages/web-renderer/src/create-scaffold.tsx
+++ b/packages/web-renderer/src/create-scaffold.tsx
@@ -11,6 +11,9 @@ export type ErrorHolder = {
error: Error | null;
};
+// React 19 currently reports this wrapper message through onUncaughtError()
+// for some uncaught render failures. This string is not part of a public API,
+// so keep this list in sync when upgrading React.
const GENERIC_REACT_RENDER_ERROR_MESSAGES = new Set([
'Error thrown during rendering',
]);
@@ -90,6 +93,8 @@ const normalizeUncaughtReactError = (
cause instanceof Error &&
GENERIC_REACT_RENDER_ERROR_MESSAGES.has(err.message);
+ // Only unwrap known generic wrappers so intentional custom wrappers can
+ // still bubble up unchanged.
const errorToThrow = shouldUnwrapCause ? cause : err;
return appendComponentStack(errorToThrow, componentStack);
}
diff --git a/packages/web-renderer/src/test/error-propagation.test.tsx b/packages/web-renderer/src/test/error-propagation.test.tsx
index 92a66a53a4..89dbff08b7 100644
--- a/packages/web-renderer/src/test/error-propagation.test.tsx
+++ b/packages/web-renderer/src/test/error-propagation.test.tsx
@@ -82,6 +82,9 @@ test('should propagate useful errors for non-Error throw values', async () => {
});
test('should unwrap generic React wrapper errors and keep useful stack', async () => {
+ // Unit-style normalization test: We synthesize the wrapper shape that
+ // normalizeUncaughtReactError() handles, instead of asserting React itself
+ // always emits this wrapper in onUncaughtError().
const ThrowsWrappedReactStyleError: React.FC = () => {
useEffect(() => {
throw new Error('Error thrown during rendering', {