Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.
https://docs.telegram-mini-apps.com/
MIT License
693 stars 191 forks source link

[Bug]: `requestContact().catch()` not able to catch any error thrown such as User denied access error #549

Closed ashelabs23 closed 4 days ago

ashelabs23 commented 5 days ago

Telegram Application

Telegram Desktop

Describe the Bug

When calling requestContact() chained with .catch(e=>console.error(e)), it will still result in uncaught promise in error.

To Reproduce

Steps to reproduce the behavior:

useEffect(() => {
        if (isTele) {
            if (isAccessGranted) {
                if (phoneRetrievalSupported) {
                    // request for phone number
                    requestContact()
                        .then((contact) => {
                            const {
                                contact: { phoneNumber },
                            } = contact;
                            teleFormObj.setValue("phoneNumber", phoneNumber);
                        })
                        .catch((e) => {
                            console.error("Some error", e);
                            // throw e;
                        });
                }
            } else if (isAccessGranted === false) {
                if (miniApp) miniApp.close();
                else redirect("/");
            }
        }
    }, [isAccessGranted, router, isTele, phoneRetrievalSupported, teleFormObj]);

Expected Behavior

Error should be caught in the .catch and console.error to console. Instead, the console.error statement is not executed and results in an uncaught error in promise

heyqbnk commented 4 days ago

Do you use the latest version of the package?

ashelabs23 commented 4 days ago

I am using the latest version of sdk-react==2.0.11