Getting The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle.

cardinaluk 41 Reputation points
2020-09-25T11:56:18.29+00:00

I'm getting the error:
The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle.
When using:

private _jeSelectPermission = async () => {
    try{
    const ler = await sp.web.lists.ensure("MyList");
    const list: IList = ler.list;

    await list.roleAssignments();
    const user = await sp.web.currentUser();

    const ReadroleDefinition = await sp.web.roleDefinitions.getByName("Read").get();
   console.log("roleDefinition : ", ReadroleDefinition);

  //  await sp.web.lists.getByTitle('MyList').items.getById(this.state.JEId).breakRoleInheritance(true);

   await sp.web.lists.getByTitle('MyList').items.getById(this.state.JEId).roleAssignments.add(user.Id, ReadroleDefinition.Id);
   const info = await sp.web.lists.getByTitle('MyList').items.getById(this.state.JEId).roleAssignments(); 
   console.log(info);
    } catch(error){
      console.log(error);
    }

  }

It works initially, so if I set permissions onto several items one by one, it works, but then starts to show these errors. Any ideas?

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,588 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jerryzy 10,566 Reputation points
    2020-09-28T03:24:44.72+00:00

    Hi @cardinaluk ,

    The code snippet works in my side based on my testing.

    And the error "The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle." should be related to Google Chrome Service Workers, it's not because of PnP Request, please check the same error here:

    The service worker navigation preload request


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments