-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
Take the following example, which (correctly) produces a redbox:
IntentAndroid.canOpenURL(url, (canOpen) => {
// Some code that can throw ...
throw new Error('This should redbox');
});
The Java signature is:
@ReactMethod
public void canOpenURL(String url, Callback callback)
Now change this to an async function:
@ReactMethod
public void canOpenURL(String url, Promise promise)
IntentAndroid.canOpenURL(url).then((canOpen) => {
// Some code that can throw ...
throw new Error('This should redbox');
});
No redbox is shown and nothing is logged which is in my opinion very poor developer experience. We've all been there - you're trying to debug a program which doesn't work but since there are no error messages and you have no idea what's wrong.
The way to "fix" this is to call done():
IntentAndroid.canOpenURL(url).then((canOpen) => {
// Some code that can throw ...
throw new Error('This should redbox');
}).done(); // Now throws and produces a redbox
But this is super easy to forget :(
For now, I'll go with a callback in the IntentAndroid. Feel like we need to find a good solution to this problem first before we migrate all APIs to async functions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.