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

'fetch' is undefined error in SPFX and out-of-the-box webparts

Open michelsmit opened this issue 7 years ago • 10 comments

Category

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

Expected or Desired Behavior

The Yammer Full Feed Webpart or other (custom) SPFX webparts using the http- or graph client should be able to render without any issues regarding the fetching of remote data.

Observed Behavior

When using the Graph client (or HTTP client) from our custom SPFX webparts the following issue occurs randomly (so not all the time, but sometimes):

"ReferenceError: 'fetch' is undefined
  at t.prototype.handleFetch (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/0.sp-http-msgraphclient_5ae609ae3611d0f0b2ab.js:1:5850)
  at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/0.sp-http-msgraphclient_5ae609ae3611d0f0b2ab.js:1:6272)
  at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-pages-assembly_nl-nl_7c0a30236f866238c82ab1edd0f121fb.js:1213:44723)
  at L (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-pages-assembly_nl-nl_7c0a30236f866238c82ab1edd0f121fb.js:8:2116)
  at T (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-pages-assembly_nl-nl_7c0a30236f866238c82ab1edd0f121fb.js:8:2232)
  at O (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-pages-assembly_nl-nl_7c0a30236f866238c82ab1edd0f121fb.js:8:2026)

This also occurs in (for example) the Yammer Full Feed webpart frequently so it's not really related to our custom SPFX webpart code. Yammer webpart shows following error:

"ReferenceError: 'fetch' is undefined
   at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-yammer-full-feed-webpart_nl-nl_139b7b0791a7a8329a4f36a6e941af8b.js:132:28114)
   at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-yammer-full-feed-webpart_nl-nl_139b7b0791a7a8329a4f36a6e941af8b.js:118:35158)
   at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-yammer-full-feed-webpart_nl-nl_139b7b0791a7a8329a4f36a6e941af8b.js:118:34471)
   at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-yammer-full-feed-webpart_nl-nl_139b7b0791a7a8329a4f36a6e941af8b.js:118:34389)
   at A (eval code:1:14872)
   at a (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/sp-yammer-full-feed-webpart_nl-nl_139b7b0791a7a8329a4f36a6e941af8b.js:118:34182)

Steps to Reproduce

Place a Yammer Full Feed webpart (or custom SPFX webpart which uses the http- or graph client) on a page and watch the console log for errors. Since the issue occurs randomly it's hard to predict when the issue shows up.

Issue occurs regularly in Edge and IE11. Environment is SharePoint Online.

michelsmit avatar Apr 25 '19 11:04 michelsmit

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

msft-github-bot avatar Apr 25 '19 11:04 msft-github-bot

hi @michelsmit - can you provide more details on what is the custom Yammer Full Feed web part you are referring to so that we can investigate the issue with more details. Thx.

VesaJuvonen avatar Apr 25 '19 11:04 VesaJuvonen

Hi @VesaJuvonen it's the Yammer Full Feed webpart which SharePoint delivers out-of-the-box. See info below taken from maintenanceMode=true:

{
  "general": {
    "alias": "YammerFullFeedWebPart",
    "id": "cb3bfe97-a47f-47ca-bffb-bb9a5ff83d75",
    "instanceId": "27520be6-1b85-4017-b814-ae8383de9091",
    "isInternal": true,
    "version": "0.0.1",
    "environment": "2",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; rv:11.0) like Gecko"
  },
  "manifest": {
    "canUpdateConfiguration": true,
    "version": "0.0.1",
    "alias": "YammerFullFeedWebPart",
    "isInternal": true,
    "loaderConfig": {
      "internalModuleBaseUrls": [
        "https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-04-12.003/"
      ],
      "entryModuleId": "sp-yammer-full-feed-webpart",
      "scriptResources": {
        "sp-yammer-full-feed-webpart": {
          "type": "localizedPath",
          "defaultPath": {
            "default": "sp-yammer-full-feed-webpart_nl-nl_139b7b0791a7a8329a4f36a6e941af8b.js"
          }
        },
        "@microsoft/office-ui-fabric-react-bundle": {
          "type": "component",
          "id": "02a01e42-69ab-403d-8a16-acd128661f8e",
          "version": "1.9.0"
        },
        "@microsoft/sp-core-library": {
          "type": "component",
          "id": "7263c7d0-1d6a-45ec-8d85-d4d1d234171b",
          "version": "1.9.0"
        },
        "@ms/sp-webpart-shared": {
          "type": "component",
          "id": "914330ee-2df2-4f6e-a858-30c23a812408",
          "version": "1.0.25"
        },
        "@microsoft/sp-webpart-base": {
          "type": "component",
          "id": "974a7777-0990-4136-8fa6-95d80114c2e0",
          "version": "1.9.0"
        },
        "@microsoft/sp-http": {
          "type": "component",
          "id": "c07208f0-ea3b-4c1a-9965-ac1b825211a6",
          "version": "1.9.0"
        },
        "@microsoft/sp-page-context": {
          "type": "component",
          "id": "1c4541f7-5c31-41aa-9fa8-fbc9dc14c0a8",
          "version": "1.9.0"
        }
      }
    },
    "manifestVersion": 2,
    "id": "cb3bfe97-a47f-47ca-bffb-bb9a5ff83d75",
    "componentType": "WebPart"
  },
  "webPartData": {
    "id": "cb3bfe97-a47f-47ca-bffb-bb9a5ff83d75",
    "instanceId": "27520be6-1b85-4017-b814-ae8383de9091",
    "title": "Gesprekken",
    "description": "Yammer-feed voor groep, gebruiker, onderwerp of startpagina weergeven",
    "serverProcessedContent": {
      "htmlStrings": {},
      "searchablePlainTexts": {},
      "imageSources": {},
      "links": {}
    },
    "dataVersion": "1.0",
    "properties": {
      "type": "All",
      "threadCount": 4,
      "title": "Yammer gesprekken"
    }
  }
}

The issue also frequently appears with custom SPFX webparts which are using the sp http client or ms graph client.

michelsmit avatar Apr 25 '19 11:04 michelsmit

Can you provide some more information? Does it happen on all browsers, or just IE/Edge? Is it possible that you have installed your own polyfill on the page via an app extension or anything?

patmill avatar Apr 25 '19 15:04 patmill

Hi @patmill, issue occurs only in IE11 and Edge. We polyfill the 'fetch' method in our code as PNP provides the fetch polyfill in @pnp/polyfill-ie11 npm package.

I can however replicate it on a blank site, using the Yammer webpart only. Please note, it's the Yammer Full Feed webpart (which is currently being rolled out to GA).

When placing the webpart on a blank homepage of a blank site, it shows up and works as expected. When I click the site icon it kind of navigates in the page, and then the fetch error occurs and the webpart shows an error. See attached screenshots.

2019-04-29_15-36-26 2019-04-29_15-39-20

michelsmit avatar Apr 29 '19 07:04 michelsmit

@michelsmit said:

We polyfill the 'fetch' method in our code as PNP provides the fetch polyfill in @pnp/polyfill-ie11 npm package.

Are you aware the SPFx already polyfills the fetch API by default as part of the HttpClient with the whatwg-fetch polyfill? Could be the two polyfills are conflicting...

andrewconnell avatar Jun 04 '19 14:06 andrewconnell

Have you reviewed the recently published supported browsers docs here: https://support.office.com/en-us/article/Which-Browsers-Work-With-Office-Online-AD1303E0-A318-47AA-B409-D3A5EB44E452

Pay special attention to the IE11 node for the modern experience & IE's document mode.

If you continue to have the issue, please comment back with some additional context. Thanks!

andrewconnell avatar Aug 09 '19 20:08 andrewconnell

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within next 7 days of this comment. Thank you for your contributions to SharePoint Developer activities.

msft-github-bot avatar Aug 16 '19 21:08 msft-github-bot

Closing issue due no response from original author. If this issue is still occurring, please open a new issue with additional details. Notice that if you have included another related issue as additional comment on this, please open that also as separate issue, so that we can track it independently.

msft-github-bot avatar Aug 23 '19 22:08 msft-github-bot

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 24 '20 12:01 msft-github-bot