Skip to content

@microsoft/teams-js Error: SDK initialization timed out #2769

Open
@DanielCutter

Description

@DanielCutter

Hi all,

I'm building a tab app and am trying to authenticate using '@microsoft/teams-js' like so:

    const init = async (): Promise<void> => {
      console.log('Initializing MSFT client...')
      await microsoftTeams.app.initialize()
      setIsInitialized(true)
      console.log('MSFT client initialized')
      const authToken = await microsoftTeams.authentication.getAuthToken()
      console.log('MSFT auth token:', authToken)
    }

I'm testing my app in the desktop client but my app is timing out when trying to call microsoftTeams.app.initialize().

I'm having to try and use this new flow as MSAL popups seem to be blocked in the desktop version of Teams. If that's not the case please let me know so I can avoid this headache 😄

As it stands, this times out every single time - am I missing something?

Using: microsoft/teams-js v2.35.0

Activity

self-assigned this
on Mar 31, 2025
Prasad-MSFT

Prasad-MSFT commented on Mar 31, 2025

@Prasad-MSFT

Hi @DanielCutter thanks for raising your issue. Does the SDK initialization time out in Teams authentication popup? Is it working in Teams web?

DanielCutter

DanielCutter commented on Mar 31, 2025

@DanielCutter
Author

Hi @DanielCutter thanks for raising your issue. Does the SDK initialization time out in Teams authentication popup? Is it working in Teams web?

Hi @Prasad-MSFT sorry for deleting the other message - I've just ran it in the web version of teams with verbose logs enabled and I get the same error:

Uncaught (in promise) Error: SDK initialization timed out.

In neither the web app or the desktop app is a popup being rendered.

Here are the additional verbose logs:

teamsJs:validateOrigin (2025-03-31T10:00:51.632Z): Initiating fetch call to acquire valid origins list from CDN [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
react refresh:6 teamsJs:app (2025-03-31T10:00:51.634Z): teamsjs instance is version 2.35.0, starting at 2025-03-31T10:00:51.634Z UTC (31/03/2025, 11:00:51 local) [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
react refresh:6 teamsJs:app (2025-03-31T10:00:51.635Z): teamsjs is being used from https://localhost:3000/static/js/bundle.js. Today, teamsjs can only be used from a single script or you may see undefined behavior. This log line is used to help detect cases where teamsjs is loaded multiple times -- it is always written. The presence of the log itself does not indicate a multi-load situation, but multiples of these log lines will. If you would like to use teamjs from more than one script at the same time, please open an issue at https://github.com/OfficeDev/microsoft-teams-library-js/issues [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +1ms
common.js:1 teamsJs:validateOrigin (2025-03-31T10:00:51.649Z): Fetch call completed and retrieved valid origins list from CDN [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +17ms
useAzureLogin.tsx:26 Initializing MSFT client...
useAzureLogin.tsx:27 teamsJs:communication:sendMessageToParentHelper (2025-03-31T10:00:51.691Z): Message 68f10cca-b109-403b-8129-fd6e02f07d7d (legacy id: 0) information: {actionName: 'initialize', args: Array(3)} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
useAzureLogin.tsx:27 teamsJs:communication:sendRequestToTargetWindowHelper (2025-03-31T10:00:51.692Z): Sending message 68f10cca-b109-403b-8129-fd6e02f07d7d (legacy id: 0) to parent via postMessage [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
useAzureLogin.tsx:39 current user has changed via the login flow: {}
useAzureLogin.tsx:26 Initializing MSFT client...
useAzureLogin.tsx:39 current user has changed via the login flow: {}
common.js:1 teamsJs:communication:shouldProcessIncomingMessage (2025-03-31T10:00:51.911Z): Should not process message because it is coming from the current window [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:51.911Z): Message being ignored by app because it is either coming from the current window or a different window with an invalid origin, message: MessageEvent {isTrusted: true, data: {…}, origin: 'https://localhost:3000', lastEventId: '', source: Window, …}, source: Window {0: Window, window: Window, self: Window, document: document, name: '', location: Location, …}, origin: 'https://localhost:3000' [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:52.050Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…er_size":0,"duration":9}}}}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +139ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:52.062Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…f6-4c07-b049-49af16b455dc"}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +12ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:52.169Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…a3-440f-9a00-2328dba677d6"}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +106ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:56.864Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…e5-4db7-8342-45ee79cbed8e"}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +5s
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:57.012Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"originatingScript":"m2","payload":{"guid":"d0027…d":"e3177d17-7c0f-4d61-883e-5778cc47f8b468a6cd"}}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +148ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:57.014Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…cf-4eae-b6a2-efd91f4f1956"}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +2ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:57.014Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…34-4aed-a2b6-92c5e2e0e7a4"}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +0ms
common.js:1 teamsJs:communication:processIncomingMessage (2025-03-31T10:00:57.169Z): Unrecognized message format received by app, message being ignored. Message: MessageEvent {isTrusted: true, data: '{"type":"parent","sourceFrameId":"__privateStripeC…09-4cb7-83ef-9292ceed4a22"}},"__stripeJsV3":true}', origin: 'https://js.stripe.com', lastEventId: '', source: global, …} [374d5faf-43bd-4e1c-9c58-5f337f60a59c] +155ms
appHelpers.js:1 Uncaught (in promise) Error: SDK initialization timed out.
DanielCutter

DanielCutter commented on Mar 31, 2025

@DanielCutter
Author

My Teams App is just an iframe pointing to my hosted website. Is that causing the issue perhaps?

Prasad-MSFT

Prasad-MSFT commented on Apr 1, 2025

@Prasad-MSFT

Hi @DanielCutter, could you please check the manifest for your Teams app to ensure that the correct validDomains are specified?This ensures the app recognizes the iframe's domain.
There is one way that apps could fail on init timeout issue, which is that app is not hosted in host. For example, if you are on Teams in edge and your app is loaded, and then you click those three dots on top right of your app and then select Go to Website, the app will try to be loaded in a new web page/tab. Then, since app is not hosted in host (it's not in an iframe), i.e. Teams, it will cause init timeout issue. Though based on your description, your problem might don't fall into this scenario.
Could you please also refer this thread and check the suggestions provided?

DanielCutter

DanielCutter commented on Apr 1, 2025

@DanielCutter
Author

Hi @Prasad-MSFT I'm trying to run this locally with two setups:

1.

  • My website running locally on localhost:3000
  • My teams app containing an iframe pointing to localhost:3000

2.

  • Using ngrok to forward my localhost:3000 -> a public https address
  • Using that address in my iframe and the app manifest

Here is my manifest,json validDomains:

    "validDomains": [
        "${{TAB_DOMAIN}}",
        "localhost",
        "localhost:3000",
        "https://d9b1-81-108-244-152.ngrok-free.app/"
    ]

With either configuration I'm still getting timeout issues.

I looked at the thread you linked and no solutions worked for me.

Prasad-MSFT

Prasad-MSFT commented on Apr 1, 2025

@Prasad-MSFT

Okay @DanielCutter, as we are having trouble repro'ing this issue at our end, could you please help providing a repro video along with the deployed app manifest (if possible) so that it would be easier for us to check and raise a bug if required?

DanielCutter

DanielCutter commented on Apr 1, 2025

@DanielCutter
Author

Thanks @Prasad-MSFT Here's a video run through, let me know if you need anything else, appreciate your time.

https://www.youtube.com/watch?v=MQ2e1neI_TE

Deployed manifest.json in app developer portal

{
  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.19/MicrosoftTeams.schema.json",
  "version": "1.0.0",
  "manifestVersion": "1.19",
  "id": "65f6cde4-8124-40df-8c5a-5b33687e0121",
  "name": {
    "short": "ChatExporterTeamsApplocal",
    "full": "Full name for ChatExporterTeamsApp"
  },
  "developer": {
    "name": "Teams App, Inc.",
    "websiteUrl": "https://www.example.com",
    "privacyUrl": "https://www.example.com/privacy",
    "termsOfUseUrl": "https://www.example.com/termsofuse"
  },
  "description": {
    "short": "Short description of ChatExporterTeamsApp",
    "full": "Full description of ChatExporterTeamsApp"
  },
  "icons": {
    "outline": "outline.png",
    "color": "color.png"
  },
  "accentColor": "#FFFFFF",
  "staticTabs": [
    {
      "entityId": "index0",
      "name": "Home",
      "contentUrl": "https://localhost:53000/tab",
      "websiteUrl": "https://localhost:53000/tab",
      "scopes": [
        "personal",
        "groupChat",
        "team"
      ]
    }
  ],
  "validDomains": [
    "localhost",
    "localhost:3000",
    "www.da13-81-108-244-152.ngrok-free.app"
  ]
}
Prasad-MSFT

Prasad-MSFT commented on Apr 2, 2025

@Prasad-MSFT

We have raised a bug for the same. We will inform you once we get any further update from engineering team. Thanks!

DanielCutter

DanielCutter commented on Apr 2, 2025

@DanielCutter
Author

Thanks @Prasad-MSFT ! Is there any rough time estimate on when the team will be picking up this bug? Only this is blocking me from releasing my app to the microsoft teams app marketplace.

Prasad-MSFT

Prasad-MSFT commented on Apr 2, 2025

@Prasad-MSFT

Apologies @DanielCutter , we could not share any ETA as of now. Once we get any update from engineering team, we will update you in this thread. Thanks!

DanielCutter

DanielCutter commented on Apr 2, 2025

@DanielCutter
Author

@Prasad-MSFT I managed to resolve the issue when using ngrok. Not sure how to fix it for localhost but with the ngrok route I needed to replace www. with https:// in the manifest.json and that seemed to resolve the issue.

I'm now facing a new problem but I'll raise that in a separate issue.

Genesys-AlexW

Genesys-AlexW commented on Apr 10, 2025

@Genesys-AlexW

We're running into a similar issue. Issue started around April 4, 2025.

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @adamreisnz@DanielCutter@Prasad-MSFT@Genesys-AlexW

      Issue actions

        @microsoft/teams-js Error: SDK initialization timed out · Issue #2769 · OfficeDev/microsoft-teams-library-js