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

SPFx WebPart on appagehost.aspx will be removed after a few seconds

Open db3005 opened this issue 6 years ago • 40 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

We have created a WebPart to render as an application page, so we leave the supportedHosts in the manifest.json empty and use the apppagehost.aspx URL to render our WebPart. The url looks like this: {siteUrl}/_layouts/15/appPageHost.aspx?componentId={componentId}.

Observed Behavior

This method worked well for a long time, now we have a problem with our first release tenant, where the WebPart is removed after a few seconds.

Steps to Reproduce

Create a new WebPart with SPFx version 1.8.2 and use the apppagehost.aspx page to render your WebPart. Our tenant is running in the first release mode, it seems like that the other tenants are not affected.

Open the URL and the WebPart will be rendered:

image

After a few seconds:

image

Html here looks like there should be a loading spinner...

image

I debuged a little bit in the SharePoint js files and found a file https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_6c1243ef07241a9f41fe54d8c7adbc98.js which probably causes the issue. In this script a _clearChildren function is called that removes the content of the web part.

image

Any Suggestions what we could do to make it work again?

db3005 avatar Dec 11 '19 09:12 db3005

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Dec 11 '19 09:12 msft-github-bot

Unless I'm mistaken, what you're doing isn't a supported scenario. That page is used to host components as tabs in Microsoft Teams. MSFT may have added logic to clear the page if a Teams context isn't detected to remove it from the page.

You may try using the current version of SPFx 1.9.1, but pretty sure this scenario isn't supported. The other option would be to set it as a full page app page to see if that works for your scenario.

andrewconnell avatar Dec 11 '19 15:12 andrewconnell

Hmm I think that for the teams tabs teamshostedapp.aspx is used. In the SPFx 1.8 release notes MSFT announced that there is a static page under appPageHost.aspx that will host any component in an app page - https://github.com/SharePoint/sp-dev-docs/wiki/SharePoint-Framework-v1.8-release-notes#app-pages - We have been using this page for almost half a year and it has always worked very well.

If we set it as a full page app page, do we need to add a page to each site collection to have this app page avaiable? That was the big advantage from the apppagehost.aspx, which is already on every site and we can simply render our component there.

db3005 avatar Dec 12 '19 12:12 db3005

@db3005 - correct. This should be supported, and you don't need to create a one-off app page .aspx in the sitepages library per site. As to why the spinner clearing is removing it - that sounds like a bug.

Are you by any chance doing rendering inside your onInit function (or in a promise resolved by your onInit function)?

patmill avatar Dec 12 '19 17:12 patmill

@patmill - No, I start my rendering only in the render function. Even if I render a single div, it will be removed after 4-6 seconds.

image -> image

db3005 avatar Dec 13 '19 08:12 db3005

Could it relate to the webpart properties panel ? In my issue #5019 I found out that I can't view the properties panel after those webparts disappeared. If I click on normal ootb webparts they show properties panel just fine, and if I click back on my custom webpart it will still show the properties panel but after I save the page and refresh, the properties panel cannot be opened again and the wp will disappear from the page.

OverkillTV avatar Dec 15 '19 04:12 OverkillTV

@patmill @andrewconnell - Any updates on this issue?

db3005 avatar Jan 10 '20 14:01 db3005

@patmill Any updates on this? This problem has reached our productive tenants.

We created a ticket yesterday and the support engineer told us that this topic is being worked on but he could not give and eta or an internal id for this problem.

MrTantum avatar Feb 18 '20 10:02 MrTantum

This issue has been fixed and will be part of the next prod rollout.

kemesfun avatar Feb 21 '20 19:02 kemesfun

@kemesfun The accepted practice in this repo is to leave issues open until the fix is actually implemented & confirmed resolved by the OP (/cc @VesaJuvonen)

andrewconnell avatar Feb 21 '20 19:02 andrewconnell

Has the prod rollout already happened? We just retested this and is still not working.

MrTantum avatar Mar 26 '20 10:03 MrTantum

@MrTantum Can you give more details of which release tenant you are on. I am getting an error now, but it is related to preloaded information on page and not with the webpart.

kemesfun avatar Mar 26 '20 23:03 kemesfun

It is a pre-release tenant:

image

Tenant ID is: b92496b8-2082-44c9-8996-26a1d0e8e3f8

MrTantum avatar Mar 27 '20 07:03 MrTantum

This is happening in my production. Not sure if relating to this but my custom web part disappear right after added to the page.

I recorded the screen for more defails: https://youtu.be/-2UWAyXuZTY

OverkillTV avatar Mar 28 '20 08:03 OverkillTV

@OverkillTV I couldn't repro this issue using a prod tenant.

The issue that I get is 'TypeError: Cannot read property 'Content' of undefined'. This is a new issue and isn't related to the original issue

kemesfun avatar Mar 30 '20 21:03 kemesfun

@db3005 can you confirm the issue has been resolved? MSFT (@kemesfun) stated the fix has been applied and rolledout.

andrewconnell avatar Mar 31 '20 10:03 andrewconnell

@andrewconnell No, unfortunately the error still occurs. I created another standard SPFx WebPart without any changes and recorded the screen:

screen-capture

db3005 avatar Mar 31 '20 12:03 db3005

@OverkillTV I couldn't repro this issue using a prod tenant.

The issue that I get is 'TypeError: Cannot read property 'Content' of undefined'. This is a new issue and isn't related to the original issue

Yeah I have 2 prod tenants. One has this issue, the other doesn't so not really sure why. They are in standard release.

OverkillTV avatar Mar 31 '20 15:03 OverkillTV

@db3005 can you do the following commands: ctrl-shift-f12. I want to see which version of sp-client you are using because it is likely that the farm that you are didn't receive the code changes that were made that resolved this issue. @OverkillTV It could be that your prod tenants are on two separate farms, so one has the newer code and the other doesn't. Can you confirm this?

kemesfun avatar Mar 31 '20 17:03 kemesfun

@kemesfun here's the screenshot:

image

Is that enough for you to see the version?

db3005 avatar Apr 01 '20 04:04 db3005