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(core): HTTP patch breaks aws-sdk v3 (or other libraries) intermittently #905

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

eliangcs
Copy link
Member

@eliangcs eliangcs commented Oct 28, 2024

Fixes an issue where a late listener of a third-party library (like aws-sdk v3) attached to HTTP response stream could miss data chunks that were already consumed by our HTTP logger. The fix involves:

  1. Replacing direct response.on('data') listener with a patched emit function so that we don't attach a listener earlier than any other listeners

  2. Maintaining the original event emission behavior by calling the original emit with all arguments

  3. Adding a test that verifies:

    • Late listeners receive complete data without missing bytes
    • Logger captures the complete response as expected

The changes also include:

  • Adding text/plain; charset=utf-8 to allowed content types

See also this video (internal-only) to walk through my thought process.

@eliangcs eliangcs requested a review from a team as a code owner October 28, 2024 07:01
Comment on lines +185 to +188
// Suppose this listener is some HTTP client library that consumes the
// response stream. We use setTimeout to recreate the scenario where
// the listener is attached AFTER the logger has already started
// consuming the stream.
Copy link
Member

Choose a reason for hiding this comment

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

Nice test 💯

@eliangcs eliangcs merged commit 3fdf6ce into main Oct 29, 2024
14 checks passed
@eliangcs eliangcs deleted the PDE-4978-http-patch-breaks-aws-sdk-v3 branch October 29, 2024 07:47
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