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

With an Event Listener for navigatedEvent - Network tab thinks all requests are being made by my code

Open MartinHatchUK opened this issue 1 year ago • 4 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
  • [ ] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

Latest SPFx build

Describe the bug / error

In my Application Customiser I am using the navigatedEvent event listener in order to enable my customiser to fire on page navigation events which do not cause a full page reload.

this.context.application.navigatedEvent.add(this, async () => { /* customiser code goes here */ }); However, when I am inspecting the Network tab in DevTools it APPEARS as though my app customiser is causing dozens of requests.

On inspection of these requests, they are actually being made by SharePoint Online itself - and for some reason my app customiser is being references as the "Source"

This is a particular issue for clients who are suggesting that my app customizer is the cause of performance problems on their site.

An example screenshot of the network tab is shown below: Many of these requests are "out of the box" SharePoint async page requests - for things like page tracking, logging activity, and various notification checks being made by the page.

Note - yes, I know the name of the JS file is "webpart" but trust me, this is actually an app customiser. Don't ask!

Image

Steps to reproduce

  1. Create a new SPFx Application Customiser
  2. Use the following snippet in your onInit() method: this.context.application.navigatedEvent.add(this, async () => { /* customiser code goes here */ });
  3. Deploy your package and check the Network Tab in Dev Tools

Expected behavior

When using the navigatedEvent event listener in my SPFx application, only requests made by my own code are referred to in Dev Tools as being requested by my code.

My code should not be listed as the "source" for out of the box SharePoint requests.

MartinHatchUK avatar May 06 '25 07:05 MartinHatchUK

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

Ashlesha-MSFT avatar May 06 '25 07:05 Ashlesha-MSFT

Hello @MartinHatchUK, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thank you!

Amey-MSFT avatar May 09 '25 05:05 Amey-MSFT

Is there any resolution on this?

You confirmed the issue over 6 months ago. Do we even know at this point if there is a workaround?

MartinHatchUK avatar Nov 05 '25 15:11 MartinHatchUK

@MartinHatchUK, Apologies — I completely understand your frustration. Six months without a resolution or workaround is unacceptable.

I tested this using SPFx 1.22.0-beta.4 and couldn’t reproduce the issue, which suggests that something may have changed in the more recent builds.

Could you please confirm which SPFx version you’re experiencing this in, and whether you’re still seeing the same behavior?

Ashlesha-MSFT avatar Nov 06 '25 08:11 Ashlesha-MSFT