Skip to content

fix: contain exceptions thrown by consumer onLoad callback - #22

Merged
lucasbesen merged 1 commit into
unlayer:mainfrom
brenopolanski:fix/onload-callback-guard
Aug 28, 2026
Merged

fix: contain exceptions thrown by consumer onLoad callback#22
lucasbesen merged 1 commit into
unlayer:mainfrom
brenopolanski:fix/onload-callback-guard

Conversation

@brenopolanski

Copy link
Copy Markdown
Contributor

Summary

A throw from onLoad was reported as a wrapper failure even though the editor had already mounted.

Reproduction:

<ImageEditor
  image={url}
  onLoad={() => {
    setStatus('Editor ready');
    throw new Error('boom');
  }}
  onError={(error) => setStatus(`Error: ${error.message}`)}
/>
Screenshot 2026-08-28 at 11 31 55

Fix

Wrap the onLoad call in try/catch and log the callback exception with console.error, the same way fail() already contains a throwing onError.

Screenshot 2026-08-28 at 11 25 23

Note

This only happens when the consumer's own onLoad throws. Well-behaved callers are unaffected. The guard is cheap and keeps onError reserved for real wrapper failures.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@brenopolanski is attempting to deploy a commit to the Unlayer Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-image-editor Ready Ready Preview Aug 28, 2026 2:58pm

Request Review

@lucasbesen

Copy link
Copy Markdown
Member

@brenopolanski thanks for the fix!

@lucasbesen
lucasbesen merged commit af89233 into unlayer:main Aug 28, 2026
9 checks passed
@brenopolanski
brenopolanski deleted the fix/onload-callback-guard branch August 28, 2026 23:45
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.

2 participants