-
Notifications
You must be signed in to change notification settings - Fork 164
Description
There was a GitHub API outage today, which broke our OAuth integration. Not nuxt-auth-utils
's fault obviously. But the 503 from the GitHub API didn't trigger my onError
function, my web app just broke and showed a "Server Error" page.

Our logs on the server logged a " FetchError: [POST] \"https://github.com/login/oauth/access_token\": 503 Service Unavailable"
My server/routes/auth/github.get.ts
file looks like:
export default defineOAuthGitHubEventHandler({
config: {
emailRequired: true,
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
},
async onSuccess(event, { user, tokens }) {
await setUserSession(event, {
user: user,
secure: {
tokens: tokens,
},
loggedInAt: new Date(),
});
return sendRedirect(event, "/");
},
async onError(event, error) {
console.error("GitHub OAuth error:", error);
return sendRedirect(event, "/");
},
});
I know it will be rare that this happens again, but if I want to handle it better for the future, what would be the best way to handle it? Doesn't seem like I can just wrap the defineOAuthGitHubEventHandler
in my own defineEventHandler
with a try catch around it, it needs to be top level.
Should I submit a PR here to put a try catch inside of defineOAuthGitHubEventHandler
? I want to be helpful, but also I haven't done a ton of open source contributing and don't know the innards of this library super well, so sorry if that was a stupid suggestion.