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: send Buffer with length #2232

Merged
merged 2 commits into from Oct 19, 2021
Merged

fix: send Buffer with length #2232

merged 2 commits into from Oct 19, 2021

Conversation

Beretta1979
Copy link
Contributor

@Beretta1979 Beretta1979 commented Oct 18, 2021

#A buffer with length 0 should still be sent
See https://github.com/nodejs/node/blob/3f11666dc7e3a6d1221bde5145929dc72edc142e/lib/_http_outgoing.js#L788

fixes #2231

I wanted to target the 13.x branch, but that one was non existent ...

@Beretta1979
Copy link
Contributor Author

Beretta1979 commented Oct 18, 2021

The failing test (write callback is not called if the provided chunk is an empty buffer) could be fixed with changing:

const buf = Buffer.from('') req.write(null, null, reqWriteCallback)
to
req.write(null, null, reqWriteCallback)
If I look at the chainges which introduced this test it would make more sense (the description needs to change too)

@gr2m
Copy link
Member

gr2m commented Oct 18, 2021

I wanted to target the 13.x branch, but that one was non existent ...

Everything merged into current main publishes to the current version, which is 13. We only have 12.x etc branches so we can backport fixes to previous versions

The failing test (write callback is not called if the provided chunk is an empty buffer) could be fixed with changing:

const buf = Buffer.from('') req.write(null, null, reqWriteCallback) to req.write(null, null, reqWriteCallback) If I look at the chainges which introduced this test it would make more sense (the description needs to change too)

can you push the change?

@Beretta1979
Copy link
Contributor Author

I updated the unit test and also added the test which reproduces the issue

@gr2m
Copy link
Member

gr2m commented Oct 19, 2021

@all-contributors please add @Beretta1979 for code and test

@allcontributors
Copy link
Contributor

@gr2m

I've put up a pull request to add @Beretta1979! 🎉

Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

great PR, thank you 💐 I confirmed that the your test failed before adding the fix

@gr2m gr2m changed the title fix(2231): A buffer with length 0 should still be sent fix: send Buffer with length Oct 19, 2021
@gr2m gr2m merged commit 8fcc607 into nock:main Oct 19, 2021
@github-actions
Copy link

🎉 This PR is included in version 13.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Beretta1979
Copy link
Contributor Author

Thanks! And thumbs up for this nice easy to use package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mocking a request which send an empty buffer will never finalize
2 participants