Skip to content

Await deleting the auth cookie #1305

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

Merged
merged 1 commit into from
Jul 31, 2025
Merged

Await deleting the auth cookie #1305

merged 1 commit into from
Jul 31, 2025

Conversation

scotttrinh
Copy link
Collaborator

This fixes the signout route not actually deleting the auth cookie. In newer versions of Next.js, getting the cookie store is async, so this used to work, but when we fixed support for async cookies in Next.js > 15, we missed this one callsite.

This fixes the signout route not actually deleting the auth cookie.
@scotttrinh scotttrinh requested review from jaclarke and Copilot July 31, 2025 14:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the signout route where the auth cookie was not being properly deleted due to missing await keyword. The fix ensures the asynchronous cookie deletion operation completes before proceeding with the signout process.

  • Add await keyword to deleteAuthCookie() call in signout route handler
  • Ensures compatibility with Next.js versions > 15 where cookie operations are asynchronous

@@ -614,7 +614,7 @@ export abstract class NextAuth extends NextAuthHelpers {
`'onSignout' auth route handler not configured`,
);
}
this.deleteAuthCookie();
await this.deleteAuthCookie();
Copy link
Preview

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The fix correctly adds await to the asynchronous deleteAuthCookie() call. However, this change should also verify that the containing function is properly declared as async. If the parent function is not async, this will cause a syntax error.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, deleteAuthCookie is indeed async:

async deleteAuthCookie() {

@scotttrinh scotttrinh merged commit b15566c into master Jul 31, 2025
9 checks passed
@scotttrinh scotttrinh deleted the nextjs-fix-signout-bug branch July 31, 2025 15:35
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.

2 participants