Skip to content

Conversation

@Khatwangadhareddy
Copy link

Closes #51628

Summary

This PR fixes a race condition in the session middleware of the with-passport-and-next-connect example. The issue was caused by overriding
es.end with an async function, which led to API requests resolving before the session cookie was set.

Changes

  • Removed async override of
    es.end
  • Implemented
    es.on('finish', callback) to ensure session persistence
  • Prevents stalled API requests and improves session consistency

Testing

  • Run the example and check /api/auth/session response
  • Confirm session cookie is set correctly
  • Ensure no stalled requests occur

Let me know if any further changes are needed! 🚀

Closes vercel#51628

## Summary
This PR fixes a race condition in the session middleware of the with-passport-and-next-connect example. The issue was caused by overriding 
es.end with an async function, which led to API requests resolving before the session cookie was set.

## Changes
- Removed async override of 
es.end
- Implemented 
es.on('finish', callback) to ensure session persistence
- Prevents stalled API requests and improves session consistency

## Testing
- Run the example and check /api/auth/session response
- Confirm session cookie is set correctly
- Ensure no stalled requests occur

Let me know if any further changes are needed! 🚀
@ijjk ijjk added Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. Font (next/font) Related to Next.js Font Optimization. tests Turbopack Related to Turbopack with Next.js. labels Mar 22, 2025
@husseinraoouf
Copy link
Contributor

@ijjk i think we should close this pr as it is clearly a spam, sorry you have to deal with kind of behaviour

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Documentation Related to Next.js' official documentation. examples Issue was opened via the examples template. Font (next/font) Related to Next.js Font Optimization. locked tests Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

with-passport-and-next-connect redefines response end function as async

4 participants