sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SPFx Web Part placed on a page (built with the Communication Site template) causes an error that prevents the page from displaying correctly in the Microsoft Teams Android client

Open vlad-nvs opened this issue 1 year ago • 9 comments

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested

  • [ ] 💥 Internet Explorer
  • [x] 💥 Microsoft Edge
  • [x] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

  • SPFx version
  • Node.js version 1.18.7

Describe the bug / error

When adding an SPFx Web Part to a page on a Communication site, the page fails to load correctly in the Microsoft Teams Android client. In the browser Network I can see next:

Image

TypeError: Cannot set properties of null (setting 'className')

After several redirects, the page eventually loads successfully. And it's okay for most enviroments but not for the MS Teams client for Android.

I have simple MS Teams app with personal tab where I show this SharePoint page. In the MS Teams Android client (latest versions) the same error occurs, but instead of recovering, the personal tab breaks completely after the redirects:

Image

I jump into debugging and found out where this error occured:

Image

The error seems to be caused by timing/race conditions in Microsoft’s script (sp-pages-assembly_) when document.body is not yet available. Somethimes there is no error (no error.aspx redirect) and then personal tab works without issues.

The issue was originally reported during the Teams app approval process for the Teams Store.

Since this issue appears to be triggered by Microsoft-provided scripts rather than custom SPFx code (but SPFx web part should be placed on a page), could someone have a look to this?

BR Vladyslav

Steps to reproduce

  1. Create Communication site collection
  2. Add Site page. Make it as a Home page
  3. Add simple Web part to the Page
  4. Create navigation link to open this page
  5. Create MS Teams app with personal tab that shown this page
  6. Open installed Teams app on Android device
  7. Redirect few times with navigation link

As a results MS Temas tab is broken

Expected behavior

It should work for MS Teams for Android as it's working for other enviroments

vlad-nvs avatar Aug 26 '25 15:08 vlad-nvs

Hello @vlad-nvs, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

Ashlesha-MSFT avatar Aug 27 '25 04:08 Ashlesha-MSFT

@vlad-nvs, We've tested your scenario in our own tenant using the same setup (Communication Site + SPFx Web Part hosted as a personal tab in Microsoft Teams Android app), but we were not able to reproduce the rendering error. Given that the page renders correctly for us, we suspect the issue may be environment-specific and potentially related to:

  • A timing issue in the current page or web part
  • An incomplete or invalid Teams manifest
  • Race conditions introduced by custom scripts or logic within the SPFx component
  • Caching or differences in Teams Android client versions

To assist you further, I’m sharing a validated manifest that we confirmed works correctly with the same SharePoint page in Teams:

{
  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.22/MicrosoftTeams.schema.json",
  "version": "1.0.0",
  "manifestVersion": "1.22",
  "id": "b22714b9-0a6d-4815-80fd-35169983ba1c",
  "name": {
    "short": "communication",
    "full": "Communication Site Tab"
  },
  "developer": {
    "name": "Contoso Ltd.",
    "mpnId": "0000000",
    "websiteUrl": "https://www.contoso.com",
    "privacyUrl": "https://www.contoso.com/privacy",
    "termsOfUseUrl": "https://www.contoso.com/terms"
  },
  "description": {
    "short": "View your communication site",
    "full": "This Teams app allows you to view the Communication Site Home Page in a personal tab."
  },
  "icons": {
    "outline": "outline.png",
    "color": "color.png"
  },
  "accentColor": "#FFFFFF",
  "staticTabs": [
    {
      "entityId": "comm-site-home",
      "name": "Comm Site",
      "contentUrl": "https://{{DomainName}}.sharepoint.com/sites/communicationsite/SitePages/Home.aspx",
      "scopes": [
        "personal"
      ]
    }
  ],
  "validDomains": [
    "{{DomainName}}.sharepoint.com"
  ]
}
Image

Ashlesha-MSFT avatar Aug 27 '25 06:08 Ashlesha-MSFT

Hi @Ashlesha-MSFT .

Thx for the feedback. We are also using SSO for SharePoint, and in the manifest, we have the following configurations:

"validDomains": [ "{teamSiteDomain}" ], "webApplicationInfo": { "id": "00000003-0000-0ff1-ce00-000000000000", "resource": "https://{teamSiteDomain}" }

Manifest has version 1.12.

As I know, this is a valid configuration for the manifest. As well, we always clear the cache for the MS Teams app

The issue occurs intermittently when a user navigates to a SharePoint page multiple times from the list view or repeatedly clicks the navigation link (configured to open the home page).

Even when the page is opened directly in a desktop browser, it sometimes redirects to error.aspx.

In the browser’s Developer Tools (Edge or Chrome), you can observe the redirect in the Network tab if you enable Preserve logs and filter by error.aspx. This becomes visible after reloading the page several times:

Image

To see the error, it’s enough to open a SharePoint page with an SPFx web part on a Communication site.

This behavior is not specific to Microsoft Teams itself, but it significantly impacts the Teams mobile client on Android, where it can cause frequent, random crashes during navigation (while on other environments (including MS Teams for iOS) it works correctly, even with a redirect to error.aspx).

BR Vladyslav

vlad-nvs avatar Aug 27 '25 09:08 vlad-nvs

@vlad-nvs, Thank you for the detailed information you've provided so far. I tested using the same SSO settings you shared, including webApplicationInfo and validDomains in the manifest. I added an SPFx web part to a Communication Site page, shown in a personal tab in Teams on Android. After multiple attempts, clearing cache and reloading, I couldn't reproduce the issue on my side.

Could you please share your SPFx project (zip or package)? That would help us replicate your exact setup. In the meantime, I’ll check with our engineering team, to explore any possible platform-level causes.

Thanks for your help — I’ll keep you updated on any findings.

Ashlesha-MSFT avatar Aug 27 '25 12:08 Ashlesha-MSFT

Hi @Ashlesha-MSFT

You can use a sample from here (simple hello world web part): https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part

But we use the next configuration in write-manifest.json (relative URL to some library on a site). After the scripts are ready, you can copy them to this library on the site.

Image

And as well package-solution.json (includeClientSideAssets set to false)

Image

And as well package.json (just SPFx version I used, but I think it doesn't matter)

Image

We this sample and changes in JSON files, I can see an error.aspx in the Network tab after a few refreshes

Image

BR Vladyslav

vlad-nvs avatar Aug 28 '25 15:08 vlad-nvs

@vlad-nvs, Thanks for sharing the details around the SPFx Web Part issue on the Communication Site page in the Microsoft Teams Android client I’ve tried replicating the setup using the configuration you mentioned,

  • Manifest Validation

Could you please confirm if the id in your Teams manifest matches the one in the file path: src\webparts\teamsAndroidCrashTest\TeamsAndroidCrashTestWebPart.manifest.json?

  • CDN Path Configuration

Please ensure the CDN path is configured as an absolute URL in your write-manifest.json. Relative paths might contribute to the timing/race condition issues you observed.

To assist with reproducing the issue in our environment, could you kindly share a sample .sppkg or zipped SPFx project that includes your current setup? I’ve tried replicating it using the details you provided, but having your exact configuration would be very helpful.

Thanks again for your help!

Ashlesha-MSFT avatar Sep 01 '25 19:09 Ashlesha-MSFT

Hi @Ashlesha-MSFT

The ID for Teams minifaest is correct For now we cannot use absolute URLs in SPFx solution we have.

Attached a zipped SPFx project of Hello World Webpart with my configurations (check write-manifest.json, package.json).

BR Vladyslav

HelloWorldWebpart.zip

vlad-nvs avatar Sep 02 '25 12:09 vlad-nvs

@vlad-nvs, Thanks for providing SPFx project, I tested your project on my end and was able to get the expected output successfully.

However, if you're uploading the .sppkg file for use in Microsoft Teams, please ensure the manifest(src\webparts\hellowWorld\HellowWorldWebPart.manifest.json) includes appropriate configuration for Teams hosting:

"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp"]

Additionally, make sure to update the following values in the manifest before uploading: contentUrl, resource, validDomains For your reference, I’ve attached a working .zip of the app package. You can use it as a template — just update the contentUrl, validDomains, and resource fields as needed for your environment.

Let me know if you run into any issues or need further assistance.

sample.zip

Ashlesha-MSFT avatar Sep 03 '25 07:09 Ashlesha-MSFT

Hi @Ashlesha-MSFT

Thanks for the suggestions.

For now, I’ve found a workaround by adding the additional parameter noredir=true to the URL when navigating to the page. With this parameter, the redirect to error.aspx is skipped, and only a console error is logged in the browser. This also resolves the issue for Microsoft Teams on Android devices.

I believe the root cause of the problem is the use of relative URLs for script resources in my SPFx solution. I’ve opened a separate GitHub issue to track this.

When I use absolute URLs for the scripts, no errors appear in either the Network tab or the console.

BR Vladyslav

vlad-nvs avatar Sep 11 '25 14:09 vlad-nvs