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

feat: dump interceptor #3118

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

feat: dump interceptor #3118

wants to merge 23 commits into from

Conversation

metcoder95
Copy link
Member

@metcoder95 metcoder95 commented Apr 14, 2024

This relates to...

Rationale

Relates to #2835

Changes

  • feat: add dump interceptor
  • fix(types): interceptor definitions

Features

Bug Fixes

Breaking Changes and Deprecations

Status

@metcoder95 metcoder95 requested a review from ronag April 14, 2024 13:53
return true
}

// TODO: shall we forward the rest of the data to the handler or better to abort?
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggestions? I might be had it wrong here 🤔

Copy link
Member

Choose a reason for hiding this comment

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

you must keep the data flowing from the request or error/abort it. The latter will destroy the connection. It should be a user choice, but I would error/abort the socket by default.

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

Should the dump interceptor should also dump on abort?

lib/interceptor/dump.js Outdated Show resolved Hide resolved
docs/docs/api/Dispatcher.md Outdated Show resolved Hide resolved
lib/interceptor/dump.js Outdated Show resolved Hide resolved
@metcoder95
Copy link
Member Author

Should the dump interceptor should also dump on abort?

Do you mean to not directly abort the connection, but rather let it flow? Or how so?

@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 90.29851% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 94.15%. Comparing base (8c3d42a) to head (4492ab7).

Files Patch % Lines
lib/interceptor/dump.js 90.15% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3118      +/-   ##
==========================================
- Coverage   94.17%   94.15%   -0.03%     
==========================================
  Files          90       91       +1     
  Lines       24559    24692     +133     
==========================================
+ Hits        23128    23248     +120     
- Misses       1431     1444      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

docs/docs/api/Dispatcher.md Show resolved Hide resolved
return true
}

// TODO: shall we forward the rest of the data to the handler or better to abort?
Copy link
Member

Choose a reason for hiding this comment

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

you must keep the data flowing from the request or error/abort it. The latter will destroy the connection. It should be a user choice, but I would error/abort the socket by default.

@metcoder95 metcoder95 requested a review from ronag April 17, 2024 10:37
@metcoder95 metcoder95 mentioned this pull request Apr 19, 2024
12 tasks
@mcollina
Copy link
Member

@ronag ptal

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

I have more opinions. Will try to have a better look as soon as I can.

lib/interceptor/dump.js Outdated Show resolved Hide resolved
lib/interceptor/dump.js Outdated Show resolved Hide resolved
Co-authored-by: Robert Nagy <ronagy@icloud.com>
lib/interceptor/dump.js Outdated Show resolved Hide resolved
lib/interceptor/dump.js Outdated Show resolved Hide resolved
lib/interceptor/dump.js Outdated Show resolved Hide resolved
lib/interceptor/dump.js Outdated Show resolved Hide resolved
lib/interceptor/dump.js Outdated Show resolved Hide resolved
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

I would remove waitForTrailers. Just makes things complicated for an edge case.

metcoder95 and others added 2 commits April 25, 2024 09:46
Co-authored-by: Robert Nagy <ronagy@icloud.com>
@metcoder95 metcoder95 requested a review from ronag April 25, 2024 10:49
@metcoder95
Copy link
Member Author

@ronag can you take a look; I'll fix the remaining test later today

this.#abort(this.#reason)
return false
}
this.#handler.onData('')
Copy link
Member

Choose a reason for hiding this comment

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

This is strange?

Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise the request keeps hanging, tried a workaround without luck; find it quite counterintuitive but most likely is something that might need to be addressed at the request level, but not sure the scope of this PR

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to address this before landing. Do you have minimal a repro? I can take a look.

Copy link
Member Author

Choose a reason for hiding this comment

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

nvm, I found the issue; it was on me, the request was in the aborted state and couldn't continue because already aborted but I never called the onError hook from the original handler. That made the work

lib/interceptor/dump.js Outdated Show resolved Hide resolved
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

Just to be clear for me here are two cases:

  1. You want to dump the response regardless
  2. You want to dump the response, if aborting and avoid closing the connection

I guess the follow configuration apply at the moment:

  1. { maxSize: 16 * 1024, dumpOnAbort: true }
  2. { max Size: 9999999999, dumpOnAbort: true }

@metcoder95
Copy link
Member Author

Just to be clear for me here are two cases:

  1. You want to dump the response regardless
  2. You want to dump the response, if aborting and avoid closing the connection

I guess the follow configuration apply at the moment:

  1. { maxSize: 16 * 1024, dumpOnAbort: true }
  2. { max Size: 9999999999, dumpOnAbort: true }

These are inclusive.
If:

  1. You want to dump the response regardless

This usually means you want to keep the connection alive, just dump the response's body, with the current setup is possible, even with the defaults.

  1. You want to dump on abort

This is also already covered, with the defaults.

  1. You want both, dump regardless, and dump on abort.

The default does that

  1. Want to dump on abort only but not regardless

This is not currently covered as regardless of the combination, you'll still be dumping the response even if not aborted; do we want to cover this case?
I imagined that if you want to use the dump is because you don't care about the response's body.

  1. Want to dump regardless but not on abort

Already covered by disabling dumpOnAbort: false

Anything else that I might be missing?

@metcoder95
Copy link
Member Author

It seems only fails on windows but cannot understand fully why 🤔

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.

interceptors does not have any exported type
5 participants