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

'Allow debug scripts' popup only showing once

Open MatthiasDh opened this issue 6 years ago • 40 comments

Category

  • [x] Bug

Describe the bug

When I'm serving a WebPart it opens the browser to the corresponding page in my serve.json file. I get the popup screen to allow debug scripts. However when I reload my page it doesn't show this popup anymore only on initial serve. By this popup not showing anymore I can't debug my webpart.

Expected behavior

Every refresh shows the 'Allow debug scripts' popup

Developer environment

  • OS: [MacOS]
  • Browser(s): [Chrome, Edge, Safari]
  • Tooling: [VS Code, SPFx]

Additional context

This issue happend out of nowhere, didn't change anything.

Serve.json file:

{
  "$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
  "port": 4321,
  "https": true,
  "initialPage": "https://localhost:5432/workbench",
  "api": {
    "port": 5432,
    "entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
  },
  "serveConfigurations": {
    "default": {
      "pageUrl": "https://xxxxx.sharepoint.com/Sites/IntranetContoso/SitePages/dev-page.aspx",
      "customActions": {
        "2dc60fe8-90cf-49ce-8650-7d0d6da14bf1": {
          "location": "ClientSideExtension.ApplicationCustomizer",
          "properties": {
            "testMessage": "Test"
          }
        }
      }
    }
  }
}

@andrewconnell editted code fencing (use 3 backticks, not 2, for fenced blocks) for readability

Thanks for your contribution! Sharing is caring.

MatthiasDh avatar Feb 26 '20 12:02 MatthiasDh

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

msft-github-bot avatar Feb 26 '20 12:02 msft-github-bot

I got the same issue with a few tenants starting on monday. The debugging popup stops showing after the first approval. I noticed that an item with the key "spfx-debug" is set to your browsers session storage. On page loads after the first approval, the debugging popup does not show up and my solutions won't load correctly from localhost.

If I remove that session storage item, I can continue working as before. All page loads require explicit confirmation for debugging. I guess there might be some kind of a change that only requires you to approve once and it's not working.

A quick hack that I'm using currently to circumvent the issue:

sessionStorage.setItem("spfx-debug", "");

Adding this to your webpart/application customizer onInit() -method, so the spfx-debug -item is cleared on each pageload. I guess you could also use sessionStorage.removeItem("spfx-debug") as well.

jhholm avatar Feb 26 '20 13:02 jhholm

@jhholm this fixed my issue for now! I hope they fix this soon, thank you! :)

MatthiasDh avatar Feb 26 '20 14:02 MatthiasDh

@MatthiasDh Web part? You mean extension?

Can you share more context? Have you tested in an SR or TR tenant?

andrewconnell avatar Feb 26 '20 23:02 andrewconnell

The more context details you can provide, the easier it is to help assist on issues. Any code you can provide and/or screenshots of the issue also help. The easier you can make it to reproduce the issue, the easier and quicker it is for someone to help you. Please refer to How to Create Good Issues, specifically How to Create Good Issues: Include context, in our wiki for more details.

msft-github-bot avatar Feb 26 '20 23:02 msft-github-bot

@andrewconnell I mean a SPFx WebPart.

Every tenant that I tested this in is TR I think.

This issue is happening in a SharePoint Online tenant and multiple tenants are having the same issue.

Tested in chrome, firefox, newest edge they all have the same issue. Same issue on macOS and windows 10. Also tried with different users.

When running the command 'gulp serve' it opens the browser and it serves my code and gives me the 'allow debug scripts' popup.

When I reload the page it doesn't show that popup anymore so it doesn't serve.

The fix of @jhholm works by clearing that cache key so it is probably caching related. However this suddenly started happening.

MatthiasDh avatar Feb 27 '20 08:02 MatthiasDh

same issue here working on an extension. I notice in the debug console that the /temp/manifests.js gets loaded when i refresh but not the actual package.

russgove avatar Feb 27 '20 23:02 russgove

Hi, we have been seeing this problem for a few days now, intermittently to begin with, but now our whole team is seeing it.

As our work is entirely done in SP Debug, this is a massive problem preventing us from working effectively.

To be SUPER explicit, we have made a webpart and we output a .sppkg that we deploy with AppCatalog.
We are running our project with gulp serve and loading the scripts in our SP tenant using the string ?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js

The first time, when we paste this string into the browser, we get the popup. But for any subsequent reloads, we don't get the popup asking to load debug scripts.

We will try the fix suggested above by jholm but we can't ship that hack in the production version of our app, and we're only human, so it'll eventually make it out with the production app somehow.

We need this fixed ASAP so SP returns to the normal behaviour of always asking to load the debug scripts regardless of whether they have been loaded before.

louis-atvero avatar Feb 28 '20 09:02 louis-atvero

Same issue here with a "target release for selected users" tenant (I'm not included in this selected users group).

Thanks @jhholm for the workaround, this one does help massively for debugging purposes.

reusto avatar Feb 28 '20 10:02 reusto

Same issue here.

We are running our project with gulp serve and loading the scripts in our SP tenant using the string ?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js

The first time, when we paste this string into the browser, we get the popup. But for any subsequent reloads, we don't get the popup asking to load debug scripts.

The workaround suggested by @jhholm it doesn't work for us because we are testing our webpart within Teams Web.

yukumura avatar Feb 28 '20 11:02 yukumura

See #5395 for another workaround

andrewconnell avatar Feb 28 '20 12:02 andrewconnell

Same here, started happening several days ago

When appending the ?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js

We never had any issues like this for the past year in our current project. Same spfx version, same test site. It just started happening suddenly

This is a real showstopper.

Adding sessionStorage.setItem("spfx-debug", ""); to the Init() in web part does not solve the issue in our case

djmrky avatar Feb 28 '20 14:02 djmrky

You could also try to manually clear your session storage via your browsers developer tools. That's how I started searching for the issue culprit. If that 'spfx-debug' item already exists, the popup will not show again and thus the "hacky fix" within Init will not work as your development code is not being run.

jhholm avatar Feb 28 '20 15:02 jhholm

Same issue on our first release tenants. The sessionStorage.setItem("spfx-debug", ""); fixes this for us though. Thanks @jhholm!

henkterharmsel avatar Feb 28 '20 15:02 henkterharmsel

I got the same issue with a few tenants starting on monday. The debugging popup stops showing after the first approval. I noticed that an item with the key "spfx-debug" is set to your browsers session storage. On page loads after the first approval, the debugging popup does not show up and my solutions won't load correctly from localhost.

If I remove that session storage item, I can continue working as before. All page loads require explicit confirmation for debugging. I guess there might be some kind of a change that only requires you to approve once and it's not working.

A quick hack that I'm using currently to circumvent the issue:

sessionStorage.setItem("spfx-debug", "");

Adding this to your webpart/application customizer onInit() -method, so the spfx-debug -item is cleared on each pageload. I guess you could also use sessionStorage.removeItem("spfx-debug") as well.

@jhholm Can you explain a little more where to put this within the webpart?

jrichmond4 avatar Feb 28 '20 15:02 jrichmond4

@jrichmond4 onInit should work. I did put it in the render, and this also works.

henkterharmsel avatar Feb 28 '20 16:02 henkterharmsel

If you are using Chrome, I would start by clearing the session storage manually via developer tools. If that fixes your problem, you can also test by clearing that exact item in developer tools console sessionStorage.removeItem("spfx-debug") There are two reasons why it might not work onInit. If if the item is already set, no code from your local development solution will be run. Secondly I'm not 100% sure that the item is always set before onInit is run. For me it does work that way. If that is the case, you could also use setTimeout to clear the item e.g. 5 seconds after onInit -call.

Remember, that this is just a hacky way to circumvent this issue and you should not leave it in production code.

jhholm avatar Feb 29 '20 12:02 jhholm

Any news? As I mentioned last friday the solution to clear the session storage cannot work for us because to reach Teams Web for debug our webpart we must necessarily go first from a Sharepoint page where the debug is loaded with a popup.

In this way we are unable to debug our webpart within a teams tab.

yukumura avatar Mar 02 '20 08:03 yukumura

A fix should be rolling out. If folks are still experiencing issues tomorrow, feel free to @ mention me. Thanks!

johnguy0 avatar Mar 02 '20 23:03 johnguy0

This is working now today . I am getting the prompts and changes reflected Browser : MS edge (chromium) @johnguy0 . Thank you.

rabwill avatar Mar 02 '20 23:03 rabwill