Skip to content

TypeError: Failed to fetch at c when trying to attach files in SPFx #9705

@Anitha-1997

Description

@Anitha-1997

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
  • 💥 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

  • browser version - 124.0.6367.61(chrome version)
  • SPFx version - SharePoint Online 1.18.2
  • Node.js version - v18.20.0

Describe the bug / error

I have deployed the solution in prod. Attachments are failing to get uploaded to sharepoint from deployed spfx solution. It works properly in most of the scenario. But some users are getting an issue. Attachments doesn't seems to get attached. And it provides a log as below:

TypeError: Failed to fetch
at c (https://publiccdn.sharepointonline.com/dummysitename.sharepoint.com/sites/AppStore/ClientSideAssets/f25c455d-16ce-453c-8f3f-538e4eaf03c3/biz-ops-app-webpart-web-part_d477373f36853ac282e0.js:2:1171724)
at c (https://publiccdn.sharepointonline.com/dummysitename.sharepoint.com/sites/AppStore/ClientSideAssets/f25c455d-16ce-453c-8f3f-538e4eaf03c3/biz-ops-app-webpart-web-part_d477373f36853ac282e0.js:2:1171803)
at async https://publiccdn.sharepointonline.com/dummysitename.sharepoint.com/sites/AppStore/ClientSideAssets/f25c455d-16ce-453c-8f3f-538e4eaf03c3/biz-ops-app-webpart-web-part_d477373f36853ac282e0.js:2:1168482

Steps to reproduce

Here is the code I'm running,

const newProjectVariation: IItemAddResult = await sp.web.lists
.getByTitle("DC-SS-ProjectVariations")
.items.add(newVariationProject);
try {
const item: IItem = sp.web.lists
.getByTitle("DC-SS-ProjectVariations")
.items.getById(newProjectVariation?.data?.Id);
 for (let i = 0; i < values.attachedFiles.length; i++) {
    const file = values.attachedFiles[i];
    await item.attachmentFiles.add(file.name, file);
  }
} catch (err) {
  await sp.web.lists.getByTitle("DC-SS-Logs").items.add({
    Title: err.message,
    LogType: "Error",
    CodeFileName: "ProjectVariationServices",
    MethodName: "createSubmitProjectVariation/fetch-data",
    StackTrace: err.stack,
    AffectedUserId: userID,
    Response: err?.response?.url,
    Status: err.status,
    StatusText: err.statusText,
  });
  throw new Error(err);
}

Expected behavior

I'm trying to create a new item in list and if there are any attachments added to a formik form, I am updating that item with the attachments in sharepoint using pnp/sp.

Metadata

Metadata

Assignees

Labels

Needs: Author FeedbackAwaiting response from the original poster of the issue. Marked as stale if no activity for 7 days.Needs: Triage 🔍Awaiting categorization and initial review.type:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions