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

discovery errors should be handled in express middleware #371

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

adamjmcgrath
Copy link
Contributor

Description

getClient starts the issuer discovery which can fail due to network conditions.

Move getClient into the try ... catch block so any discovery errors it throws can be caught and handled in Express mw

(Best to look at this PR with "ignore whitespace")

References

fixes #370
https://expressjs.com/en/guide/error-handling.html#catching-errors

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@adamjmcgrath adamjmcgrath added the review:small Small review label Jun 28, 2022
@adamjmcgrath adamjmcgrath requested a review from a team as a code owner June 28, 2022 15:48
@@ -7,22 +7,22 @@ let warn;

beforeEach(function () {
warn = sinon.stub(global.console, 'warn');
nock('https://op.example.com', { allowUnmocked: true })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed we didn't need these (all requests should be mocked)

@adamjmcgrath adamjmcgrath merged commit 0849939 into master Jun 29, 2022
@adamjmcgrath adamjmcgrath deleted the handle-discovery-errors branch June 29, 2022 13:54
@adamjmcgrath adamjmcgrath mentioned this pull request Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:small Small review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to catch Issuer.discover failure?
2 participants