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

Using multiple AadHttpClient 's / MSGraphClient' s doesn't work anymore

Open Nasicus opened this issue 8 years ago • 6 comments

Category

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

SFPX version 1.4.1.

In our SPFx app (with react), we're using the AadHttpClient and MSGraphClient. Starting about one week ago we're having heavy issues concerning these two clients. Our app has become completely unusable!

In our app we're using multiple instances of the AadHttpClient (to different resources/api's) and also the MSGraphClient from within the same web part (therefore using the same serviceScope).

However only the first call is executed. The other calls will never be executed and are not even visible in the network tab. The only time it sometimes still works is, if you open a new anonymous browser session and access the page for the first time (I guess because the local/session storage is still empty). But already on the second refresh it won't work anymore for all but the first request. Note that after the first request is done and the other two have failed, not even the first client works anymore. So if you want to use the first client again later, it will also not work (with the same behavior: no request will even be sent out).

Is this bug already known? If so when will it be fixed? Is there a work around?

Any help is appreciated, since this is a critical issue for us!

Code Snippet (simplified):

export class WhatEverWebPart extends BaseClientSideWebPart<IWebPartProperties> {
    public render(): void {
        // first api
        const firstClient: AadHttpClient = new AadHttpClient(this.context.serviceScope,
                                                             "http://myAppIdentifier");
        firstClient.get("http://my-api", AadHttpClient.configurations.v1)
                   .then((response: HttpClientResponse): Promise<any> => {
                       console.log(response);
                   });

        // second api
        const secondClient: AadHttpClient = new AadHttpClient(this.context.serviceScope,
                                                              "http://mySecondAppIdentifier");
        secondClient.get("http://my-second-api", AadHttpClient.configurations.v1)
                    .then((response: HttpClientResponse): Promise<any> => {
                        console.log(response);
                    });

        // ms graph
        this.context.serviceScope.consume(MSGraphClient.serviceKey)
            .api("http://graph-url")
            .get()
            .then(result => console.log(result));

        return (
            <div>
                hi
            </div>
        );
    }
}

Nasicus avatar Jun 01 '18 16:06 Nasicus

We had the exact same issue, but as of this morning all calls are going through and now return error 403. We've tried re-approving all permission scopes/requests but no luck. Issue persists on at least 4 separate tenants, but the code used is pretty much the same (all MSGraphClient). Is anyone else having this issue?

justdevelopment avatar Jun 04 '18 10:06 justdevelopment

On the first pageload our MSGraphClient call (we only have one and 2 custom api calls) also return a 403 now. The others (custom apis) still have the same behavior.

After the second page load (I guess because some token is cached), the same behavior as in my initial post above happens. Halleluja!

Nasicus avatar Jun 04 '18 10:06 Nasicus

Another thing which we just found out:

When me make all callls sequential, i.e. only start calls once a response in the then (or in the error case) was received. It seems to work.....still testing this further though (and this would obviously only be a workaround).

Nasicus avatar Jun 04 '18 11:06 Nasicus

So this is still happening, but there is a "workaround". However if you do this you'll have significant performance losses,

The workaround is to do all calls sequential. In my case I introduced an AADCallManager which queues all calls and starts them after each other. However obviously the app does then become very slow ;)

Nasicus avatar Jun 06 '18 05:06 Nasicus

This is fixed again, see => https://github.com/SharePoint/sp-dev-docs/issues/1810

Nasicus avatar Jun 12 '18 09:06 Nasicus

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 27 '20 18:01 msft-github-bot