Skip to content

onUnhandledRequest: Suppress exceptions when parsing potential GraphQL requests - #740

Merged
kettanaito merged 3 commits into
mswjs:masterfrom
thomasmery:fix/#732
Jun 6, 2021
Merged

kettanaito merged 3 commits into
mswjs:masterfrom
thomasmery:fix/#732

Conversation

@thomasmery

@thomasmery thomasmery commented May 17, 2021 •

Copy link
Copy Markdown
Contributor

Tries and apply what @kettanaito suggested to avoid logging an error when an unhandled rest request containing a query param would result in a confusing error message in the console

@kettanaito please let me know if this is what you meant and/or how this can be improved

thanks

@codesandbox-ci

codesandbox-ci Bot commented May 17, 2021 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 06aaf7a:

Sandbox Source
MSW React Configuration

@kettanaito kettanaito changed the title Fix confusing error logging on unhandled request query parsing onUnhandledRequest: Suppress exceptions when parsing potential GraphQL requests May 18, 2021
Comment thread src/utils/request/onUnhandledRequest.ts Resolved
Comment thread src/utils/request/onUnhandledRequest.ts Resolved
Comment thread src/utils/request/onUnhandledRequest.ts Resolved
Comment thread src/utils/request/onUnhandledRequest.ts Resolved

@kettanaito kettanaito left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on these improvements, @thomasmery!
They look great. I've left a few comments, could you please let me know what you think about them?

Looking forward to seeing this fix merged.

@thomasmery

Copy link
Copy Markdown
Contributor Author

@kettanaito will get to it as soon as I am able :)

thanks for the guidance!

@kettanaito

Copy link
Copy Markdown
Member

Hey, @thomasmery. I've updated your feature branch against the latest state of the repo and polished the implementation a little, mainly adding missing tests. I hope you don't mind. Looks good to get it merged, waiting for the CI to pass.

kettanaito
kettanaito previously approved these changes Jun 6, 2021
return parseGraphQLRequest(request)
return tryCatch(
() => parseGraphQLRequest(request),
(error) => console.error(error.message),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling parsing exceptions as console errors to preserve the previous behavior. At the moment, when parsing a request in a graphql handler fails, it doesn't produce a 500 response, but a console error including the parsing error.

@kettanaito
kettanaito merged commit 2213b4e into mswjs:master Jun 6, 2021
@thomasmery

Copy link
Copy Markdown
Contributor Author

@kettanaito ah so sorry - it was just not possible to follow up - thanks for your kindness and this great project

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST query is mistaken for GraphQL query and can't be intercepted (throws an error)

2 participants