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

fix(fetch): await response listener before resolving the response promise #658

Merged
merged 4 commits into from
Oct 7, 2024

Conversation

mikicho
Copy link
Contributor

@mikicho mikicho commented Oct 7, 2024

  1. Added tests
  2. wait for fetch unlocked request
  3. reduce the sleep for the ClientRequest tests :)

closes #656

@kettanaito Is it OK for the then callback to be async?

@mikicho mikicho requested a review from kettanaito October 7, 2024 09:45
Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

This looks great! Thank you, @mikicho 👏

Yes, it's perfectly fine for the .then() closure to be async. Fetch understands that.

I've adjusted the test names and also added a mock function to assert on the correct order of execution. The tests pass.

@kettanaito kettanaito changed the title fix(fetch): wait for response listeners for unmocked requests fix(fetch): await response listener before resolving the response promise Oct 7, 2024
@kettanaito kettanaito merged commit 261f581 into main Oct 7, 2024
2 checks passed
@kettanaito kettanaito deleted the Michael/fetch-wait-listeners branch October 7, 2024 10:07
@kettanaito
Copy link
Member

Released: v0.36.4 🎉

This has been released in v0.36.4!

Make sure to always update to the latest version (npm i @mswjs/interceptors@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

Fetch does not await of the response listener
2 participants