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

Asynchronous Handling Issue in API Key Hashing Middleware #3338

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Jatin24062005
Copy link
Contributor

@Jatin24062005 Jatin24062005 commented Feb 8, 2025

Previously, next() was being called after hashing each API key, which caused multiple calls and issues. The new solution uses a pendingTasks counter to wait until all async operations are completed. This fix prevents Mongoose errors and premature next() calls, ensuring proper API key hashing.
The Code i have been manipulated works on the simple principle of critical section problem simmilar to peterson's solution.
These will fix the issue easily .

Fixes #issue-[3016](url)

Changes:

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

Previously, next() was being called after hashing each API key, which caused multiple calls and issues.
The new solution uses a pendingTasks counter to wait until all async operations are completed.
This fix prevents Mongoose errors and premature next() calls, ensuring proper API key hashing.
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.

1 participant