Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaos Handler not working as expected #1297

Open
5 of 6 tasks
repl-rahul-m opened this issue May 26, 2023 · 5 comments
Open
5 of 6 tasks

Chaos Handler not working as expected #1297

repl-rahul-m opened this issue May 26, 2023 · 5 comments
Assignees

Comments

@repl-rahul-m
Copy link

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.

Description

I am trying to throw some throttling errors for a graph client using js randomly with 429 status code. So I created Chaos handler and added it as a middleware for that graph request via middlewareOptions and checked it, To my surprise, it received the correct response and didn't try to throw the error.

Steps to Reproduce

  1. Initialise a graphClient using @microsoft/microsoft-graph-client
  2. Added chaos Handler something like this:
await graphClient.api(path).middlewareOptions([
          new ChaosHandlerOptions(
            ChaosStrategy.MANUAL,
            'Retry Error',
            429,
            100,
)]).get()
  1. So As the chaos percentage is 100%, I should be expecting all throtling exceptions, But it didn't happen.

Expected behavior:

I am expecting to throw error so that I can catch it and handle it accordingly.

Actual behavior:

It returns the response data from the API request.

Additional Context

Add any other context about the problem here..

Usage Information

Request ID - Value of the requestId field if you are receiving a Graph API error response

SDK Version - 3.0.5

  • Node (Check, if using Node version of SDK)

Node Version - 18.13.0

  • Browser (Check, if using Browser version of SDK)

Browser Name - [The name of Browser that you are using for SDK]

Version - [The version of the browser you are using]

@ghost ghost added the ToTriage label May 26, 2023
@sebastienlevert
Copy link
Contributor

You probably haven't added the middleware directly to the chain when initializing your Client. You can see some docs here :

https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/ChaosHandlerSamples.md

Also, we have a new offering that offers similar capabilities without the need of configuring your code. You can look at our Microsoft Graph Developer Proxy right here!

@repl-rahul-m
Copy link
Author

Thanks for your response @sebastienlevert. I am using something like this:

export const getGraphClient = (accessToken: string): Client => {
  const provider: AuthProvider = (done) => {
    done(null, accessToken);
  };

  const authHandler = new AuthenticationHandler(
    new CustomAuthenticationProvider(provider),
  );

  const chaosHandler = new ChaosHandler();

  const middlewareArray = [authHandler, chaosHandler];
  return Client.initWithMiddleware({
    middleware: middlewareArray,
  });
};

And this throws an error in lambda like this:

"Error",
        "    at new GraphError (/var/task/dist/node_modules/@replicon/tict-common/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphError.js:34:28)",
        "    at Function.<anonymous> (/var/task/dist/node_modules/@replicon/tict-common/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:97:30)",
        "    at step (/var/task/dist/node_modules/@replicon/tict-common/node_modules/tslib/tslib.js:193:27)",
        "    at Object.next (/var/task/dist/node_modules/@replicon/tict-common/node_modules/tslib/tslib.js:174:57)",
        "    at /var/task/dist/node_modules/@replicon/tict-common/node_modules/tslib/tslib.js:167:75",
        "    at new Promise (<anonymous>)",
        "    at Object.__awaiter (/var/task/dist/node_modules/@replicon/tict-common/node_modules/tslib/tslib.js:163:16)",
        "    at GraphErrorHandler.getError (/var/task/dist/node_modules/@replicon/tict-common/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:87:24)",
        "    at GraphRequest.<anonymous> (/var/task/dist/node_modules/@replicon/tict-common/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:315:84)",
        "    at step (/var/task/dist/node_modules/@replicon/tict-common/node_modules/tslib/tslib.js:193:27)"

Also it looks like there is no documentation to install the Microsoft Graph developer proxy in wsl or linux.

@repl-rahul-m
Copy link
Author

Any updates on this? We needed this to test this to see how it behaves before we push our code to production.

@sebastienlevert
Copy link
Contributor

FYI @koros. Is it possible the chaos handler has issues? Or what would be the right config to use?

@koros
Copy link
Contributor

koros commented Jul 25, 2023

FYI @koros. Is it possible the chaos handler has issues? Or what would be the right config to use?

I can't tell for sure i'd like to do more tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants