OfficeDev / microsoft-teams-library-js

JavaScript library for use by Microsoft Teams apps
https://docs.microsoft.com/microsoftteams/platform/
Other
426 stars 194 forks source link

Initialization of “app” from “@microsoft/teams-js” is timing out #1181

Open shubh30126 opened 2 years ago

shubh30126 commented 2 years ago

version: “@microsoft/teams-js” : "2.0.0-beta.4-dev.9" Error thrown: Teams js method app.initialize() Error: SDK initialization timed out. User Agent of Popup window: Mozilla/5.0 (Macintosh; Intel Mac OS X 12_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Teams/1.5.00.4683 Chrome/85.0.4183.121 Electron/10.4.7 Safari/537.36

mustafasezer commented 1 year ago

Hi @nwojod-MSFT I recently found out that app.initialize() works without problems, if I upload a custom tab app with the page served on my local machine via tunnel (like ngrok, I use loca.lt). However, if I deploy the exact same web app to aws amplify for hosting, the initialization times out. I tried it with teams-js versions 1.10.0, 2.4.1 and latest on MS Teams Linux desktop client as well as in Chrome, all of them have the same behaviour.

cgvalayev commented 1 year ago

Hey @nwojod-MSFT was the release successful, do you have any updates?

miron4dev commented 1 year ago

Hi @nwojod-MSFT @Meghana-MSFT

Do you have any updates?

JohnFTitor commented 1 year ago

Here with SDK 2.7.1, tested on Linux, Ubuntu, and Chrome web version of MSTeams, facing the exact same issue for a personal app image

@mustafasezer I confirm the behavior. The initialization works for my local environment but fails when deployed live

ChetanSharma-msft commented 1 year ago

Hello Everyone, We will check on this and let you know the updates.

Thommurgia commented 1 year ago

Hello everyone, I'm facing the same problem today, do someone have found a solution ? I tried to use msal library for angular to authenticate my customer but msal popup is blocked by teams desktop application. The solution was to use @microsoft/ms-teams but i'm timed out using app.initialize();

If someone have another solution to obtain customer token in vue to use Microsoft Graph api i'm open to solutions ! @Meghana-MSFT

sommerlilie commented 1 year ago

Hi,

we are also encountering the issue. It happened "over night". Local env works, deployed one (via Teams Toolkit) not. PersonalTab seems to be not affected. I removed all authentication-related code, did not change error behavior.

sommerlilie commented 1 year ago

I found a solution by re-deploying the App. No Code changes at all. It seems to be an issue on the Azure hosting side. At least for us.

ScottRJones commented 1 year ago

We are also having frustrating issues with SDK initialization timed out error when trying to call microsoftTeams.app.initialize(); from our Saas application.

Our aim is to develop a Microsoft Teams Message Extension capable of communicating with our Saas application after authentication with it.

Upon debugging the Teams Bot we install our Teams App:

image

We are then directed to a chat window where the extension is installed: image

Upon clicking an action button we are prompted to login: image

The sign in button then takes you to our application for authentication: image

Upon successful login within our application a JavaScript file is then loaded with the following: microsoftTeams.app.initialize();

This is failing after a few seconds with Uncaught (in promise) Error: SDK initialization timed out.

We are using the following package: "@microsoft/teams-js": "^2.9.1"

And are running ngrok to allow the connection to Local Teams Debug and our Local application Debug.

We have been hitting our head against a wall for days with this now and cannot seem to get past this error, when everything we have done is seemingly correct. It seems that many others are also having the same problem especially in recent days and weeks.

Can anyone provide any support or update on this issue please?

Thank you Scott

sommerlilie commented 1 year ago

@ScottRJones I saw your comment as I'm still keeping an eye on this issue. If you are using the Teams Toolkit, have you tried to create a new app registration and resources? We had again an app spontaneously getting this error and just replaced it by a new registration, the "new" app then worked fine.

ScottRJones commented 1 year ago

Hi @sommerlilie , thank you for your reply and suggestion. We will try this in the next day or two and report back. Kind regards Scott

ScottRJones commented 1 year ago

Morning @sommerlilie , today we have re-created the app registration by removing the existing one in Azure Portal and clicking Prepare Teams App Dependencies in VS which created a new app registration. Is this all you meant by "create a new app registration and resources"? Or is there an additional step you did as well? You mentioned "and resources?" Unfortunatley we are getting the same error.

Thank you Scott

Thommurgia commented 1 year ago

Hello everyone,

For me it's now working. To be honest I'm still student and I don't really understand why it's working...

But, if I understand a bit what's happening in my case, I moved the Authentication.authenticate method in the highest level of my app and now it's working.

Before, I called this method in one of my component where I wanted to authenticate my user. And now I'm doing this in the entry class of my program.

I'm working on a teams tab app, created with Teams Toolkit in Visual Studio Code, this app is generated in react by the toolkit. I moved this method from a component to my index.tsx file. I think it's this changing that made me solve my problem but to be honest I'm not sure.

I hope this can help some of you, don't hesitate to ping me if you want more informations.

Have a nice day, Thomas

RishavNice commented 1 year ago

Hi @shubh30126 @sumit12690 @miron4dev @mustafasezer

Did you solve the issue. Please reply. We're facing the same issue.

vvolodin commented 1 year ago

any updates on this? it's been almost a year.

Thommurgia commented 1 year ago

Nothing is working for me but I can add some informations.

I'm using this method in a Teams tab application, this is built in react with Teams toolkit from Visual Studio Code. The application start in a class named index.tsx and in this class i'm using app.Initialize().then() ...

When I launch the application in teams browzer it works properly. When I launch the application in teams desktop it doesn't work properly at a first step but when i modify something in the code and the "hot reload" reload the page then app.initiliaze works properly.

I don't understand what is the problem with this method but the behaviour is really strange.

Thomas

nwojod-MSFT commented 1 year ago

Hello all, apologies that this issue has not been resolved for such a long time. Our team has been actively working to identify the root cause of the problem in order to fix it. Unfortunately, the initial proposed solution we had in Electron 16 did not fix the bug, so our engineering team has been working hard to come up with a new solution. While we don't have a clear ETA on when this will be resolved, we want to assure everyone that we are still working tirelessly to fix the issue, and we will provide updates to the community as soon as we can identify the root cause. Thank you for your patience.

integrationworktual commented 1 year ago

Morning @ScottRJones could you please provide support to sort out this issue unhandled (in promise) Error: SDK initialization timed out. sdk error

after successfully login in javascript , calling app.initialize().then(()=> { let token ='sample token' authentication.notifySuccess(token ) }) getting Uncaught (in promise) Error: SDK initialization timed out. after 5sec am trying to sort out this issues past one week

thanks,

integrationworktual commented 1 year ago

@nwojod-MSFT would you please any update on this issue.

thanks,

ScottRJones commented 1 year ago

Morning @ScottRJones could you please provide support to sort out this issue unhandled (in promise) Error: SDK initialization timed out. sdk error

after successfully login in javascript , calling app.initialize().then(()=> { let token ='sample token' authentication.notifySuccess(token ) }) getting Uncaught (in promise) Error: SDK initialization timed out. after 5sec am trying to sort out this issues past one week

thanks,

Hi @integrationworktual We are still having the same issue here and are awaiting a response from @nwojod-MSFT . @nwojod-MSFT - can you provide an update of where a fix for this is up to now please? Thank you.

Kind regards Scott

integrationworktual commented 1 year ago

@ScottRJones thanks for your quick response ..... Is there any alternative ways to send authenticate.notifysuccess() token after login success our javascript code to communicate with team app for further @nwojod-MSFT please, can you comeup with your valuable solution as soon as possible (It's urgent we need your help) thanks, integrationWorktual

integrationworktual commented 1 year ago

@nwojod-MSFT regarding team tab module working on local debug mode only not able get a authenticate.notifysuccess() message after login third party oauth could provide a valuable feedback

regards,

ScottRJones commented 1 year ago

@nwojod-MSFT @ChetanSharma-msft @Meghana-MSFT - Please can you provide an urgent update on this? It has now been a year since this issue was first reported and we seem no closer to resolving it which is very frustrating. Thank you.

ChetanSharma-msft commented 1 year ago

I apologize for delay in response. We are actively checking the status of bug fixes with engineering team and will update this thread, once it is fixed.

Thanks!!

vhensorskyi commented 1 year ago

Team, We are also affected by the bug. It stops us from upgrading to the new version of the client. Please fix it as soon as possible.

kaneg commented 1 year ago

We have the same issue:

Uncaught (in promise) Error: SDK initialization timed out.
    at n.initialize (app.ts:570:9)
    at Module.qt (publicAPIs.ts:45:7)
    at messages?type=loginCallback:10:20
erminsabotic commented 1 year ago

We have the same issue as well

sschoeb commented 1 year ago

We are also facing this issue since the upgrade from 1.x to 2.11.0. Guess the only workaround for now is to downgrade to an older version.

@ChetanSharma-msft Any update on that would be great. Thanks.

ChetanSharma-msft commented 1 year ago

I apologize for delay in response. We are actively checking the status of bug fixes with engineering team and will update this thread, once it is fixed.

Thanks!!

nwojod-MSFT commented 1 year ago

Hello all, apologies for the delayed reply. We made a fix that we think might address this issue; it's in Teams version 1.0.0.2023052414 (web client). Can you all try this and see if you still experience the problem reported here? Thanks.

vvolodin commented 1 year ago

I keep having this issue for a couple of years now, it seems to come and go based on the client version I'm using. Currently doesn't work for me both in the app and in Chrome browser.

iliapir2 commented 1 year ago

I'm having this issue too, it would be great if library will provide some method to extend timeout maybe?

leonardjohn commented 11 months ago

We are experiencing the same problem too when we try to click "Reload tab" to reload stage view which we created via deep link from adaptive card.

ChetanSharma-msft commented 11 months ago

Hello @vvolodin - Please confirm if you are able to repro same issue in Web client as well? If yes, then it's a different issue related to initialize and please raise a separate bug.

Also, please confirm if this is happening on new Teams client as well.

mustafasezer commented 11 months ago

Hi @shubh30126 @sumit12690 @miron4dev @mustafasezer

Did you solve the issue. Please reply. We're facing the same issue.

I just found a solution (at least for my case). I was using my domain name without "www" in front. It appears that if you do not have a subdomain, the app initialization times out. I changed the Application ID URI from being api://example.com to api://www.example.com and also the redirect URI. This solved the problem in my case, I am using @microsoft/teams-js version 2.4.1.

How I came up with this: I was using tunnel for testing and AWS amplifyapp domain for "production". I checked today the DNS records and that did not help. All of a sudden I thought maybe it is because both amplifyapp and tunnel domains have subdomains, whereas the one I use is a so-called naked domain. I just tried it out and it worked

kaneg commented 9 months ago

As @mustafasezer said, he resolved the problem by changing domain name. And according to this issue: https://github.com/OfficeDev/microsoft-teams-library-js/issues/1681, someone also mentioned the domain issue. So I guess, the domain is the key problem: the domain of the page where the SDK is initialized should be in the valid domains of the App manifest: "validDomains": []

ScottRJones commented 9 months ago

We are still experiencing the same error.

We have created a new Teams project from scratch using the latest version of Visual Studio and Teams Toolkit. We are running the latest version of the teams-js npm in our main application and testing on the new version of Teams.

After returning a MessagingExtensionResult with Type="Auth" and link to our login, our application launches correctly, the user logins in successfully, after which we call the following:

microsoftTeams.app.initialize().then(() => {
});

and get the Uncaught (in promise) Error: SDK initialization timed out. error.

We have tested in Edge, Chrome, Firefox and the Teams application itself, all with the same result.

We are using NGrok for local development but have also had the exact same result on a hosted server.

Our domain appears correct. It is listed in our valid domains (**** replaced with actual address):

  "validDomains": [
    "****.ngrok-free.app"
  ]

and in the OnTeamsMessagingExtensionFetchTaskAsync method:

                var output = new MessagingExtensionActionResponse
                {
                    ComposeExtension = new MessagingExtensionResult
                    {
                        Type = "auth",
                        SuggestedActions = new MessagingExtensionSuggestedAction
                        {
                            Actions = new List<CardAction>
                           {
                               new CardAction
                               {
                                   Type = ActionTypes.OpenUrl,
                                   Value = "https://****.ngrok-free.app/Login",
                                    Text = "Please sign in",
                                    Title = "Sign in", 
                               },
                            },
                        },
                    },
                };

@ChetanSharma-msft @nwojod-MSFT - Is this still being actively looked into by the Microsoft Team?

@sommerlilie - Are you still experiencing the same issue as you were in March?

Thanks all Scott

tiennguyen1293 commented 6 months ago

We can easy to reproduce on https://teams.microsoftonline.cn

Version: "@microsoft/teams-js": "^2.14.0"

Ref: https://github.com/OfficeDev/microsoft-teams-library-js/issues/2191 Thanks all

Nefiich commented 5 months ago

I'm still having this issue. SDK fails to initialise inside the pop-up window while using ngrok for local development.

Noext commented 1 month ago

Any news on this ? Its 2024 and even with sso sample project it still bug randomly, it was working yesterday and today its not...

KangxuanYe commented 1 month ago

Hi @Noext and app developers,

We have identified some of issues might cause SDK initialization times out failure and are preparing instructions for developers so that you can resolve the issues by yourself.

In the near term, we are also preparing a logger system so that we can have rich info to understand what exactly happened on your app at the time it fails on initialization. You can still reach us and we will have more clear and detailed explanation to you once the work is completed.

Thanks for reaching and the update will be coming soon.