-
Notifications
You must be signed in to change notification settings - Fork 30
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
Marking promises as handled feels like a bad developer experience #255
Comments
Which types of mistakes are not being caught? The one that bothers me most is the return value of |
Oh, just me doing dumb stuff like: navigationEvent.intercept({
handler() {
// …
document.body.appned(…);
}
}); |
So the problem is we also want to accommodate code like await navigation.navigate("/foo").committed; where the developer really doesn't care about the navigation.navigate("/foo");
navigation.navigate("/bar"); // this will abort the finished promise for /foo. Do you care? navigation.navigate("/foo");
handleTransitionResult(navigation.transition.finished); // One part of your app:
navigation.navigate("/foo");
// Another part of your app:
navigation.addEventListener("navigateerror", (ev) => {
handleErrorCentrally(ev.error);
}); Maybe what we need is a separate concept of "unhandled navigation rejection", which can take all these things into account, so that if none of them are handled after an event loop turn, that gets logged to the console. That still doesn't solve the double- This could be done entirely as a DevTools-level thing, I guess, if we don't care about adding some sort of global Or we could just say "you really need to handle your finished promises", but I worry that makes a lot of the above code quite ugly. E.g. const result = navigation.navigate("/foo");
result.finished.catch(() => {});
await result.committed; is not an invocation you really want to see scattered throughout your codebase. Regarding TypeScript not detecting I noticed in this TypeScript playground example it gives a sort of warning, with a small dotted underline, saying " |
I think that's a good idea, and might be useful in other cases too. I don't have great ideas for the |
I keep getting caught out by this when working with the navigation API.
I'll write some code, and because I'm a 0.5x developer I make mistakes. The result won't behave as I'm expecting, so I'll open the console, and there's no error, leading me to think the problem isn't just due to an error being thrown. However, it is due to an error being thrown, but the navigation API is swallowing the error.
It feels like the API shouldn't behave like this.
The text was updated successfully, but these errors were encountered: