I have had this problem earlier and managed to solve it. What I have done is simply just put this in the homepage(first page the app is rendering) in my blazor project
`@inject TeamsUserCredential teamsUserCredential
@inject MicrosoftTeams MicrosoftTeams
protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (firstRender) { var isInTeams = await MicrosoftTeams.IsInTeams(); if (isInTeams) { UserInfo user = await teamsUserCredential.GetUserInfoAsync(); } StateHasChanged(); } }`.
Maybe the code have tried to connect to Teams by this before the timeout, so that the error disappeared? But it works for me.