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

polish: do not log the error object when refreshing a token fails #851

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/early-timers-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

polish: do not log the error object when refreshing a token fails

We handle the error anyway (by doing a fresh login) which has its own logging and messaging. In the future we should add a DEBUG mode that logs all requests/errors/warnings, but that's for later.
9 changes: 5 additions & 4 deletions packages/wrangler/src/__tests__/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("User", () => {
});

// TODO: Improve OAuth mocking to handle `/token` endpoints from different calls
it("should report error message for failed token refresh", async () => {
it("should handle errors for failed token refresh", async () => {
mockOAuthServerCallback();
writeAuthConfigFile({
oauth_token: "hunter2",
Expand All @@ -100,9 +100,10 @@ describe("User", () => {
});

// Handles the requireAuth error throw from failed login that is unhandled due to directly calling it here
await expect(requireAuth({} as Config, false)).rejects.toThrowError();
expect(std.err).toContain(
`Error: <html> <body> This shouldn't be sent, but should be handled </body> </html>`
await expect(
requireAuth({} as Config, false)
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Did not login, quitting..."`
);
});

Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,6 @@ async function refreshToken(): Promise<boolean> {
writeAuthConfigFile({ oauth_token, expiration_time, refresh_token });
return true;
} catch (err) {
console.error(err);
return false;
}
}
Expand Down