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

Merged
merged 34 commits into from May 15, 2024
Merged

feat: dump interceptor #3118

merged 34 commits into from May 15, 2024

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
13 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 <[email protected]>
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.

Comment on lines 73 to 80
if (!this.#dumped) {
if (this.#aborted) {
this.#handler.onError(this.reason)
return
}

this.#handler.onError(err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!this.#dumped) {
if (this.#aborted) {
this.#handler.onError(this.reason)
return
}
this.#handler.onError(err)
}
if (this.#dumped) {
return
}
if (this.#aborted) {
this.#handler.onError(this.reason)
return
}
this.#handler.onError(err)

Comment on lines 100 to 108
if (!this.#dumped) {
if (this.#aborted) {
this.#handler.onError(this.reason)
return
}

this.#handler.onComplete(trailers)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!this.#dumped) {
if (this.#aborted) {
this.#handler.onError(this.reason)
return
}
this.#handler.onComplete(trailers)
}
}
if (this.#dumped) {
return
}
if (this.#aborted) {
this.#handler.onError(this.reason)
} else {
this.#handler.onComplete(trailers)
}
}

}

this.#maxSize = maxSize ?? this.#maxSize
this.#dumpOnAbort = dumpOnAbort ?? this.#dumpOnAbort
Copy link
Member

Choose a reason for hiding this comment

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

How about not having this as an option and just have it always enabled? We might also want to have a dump timeout in addition to a maxSize?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this goes in line with your suggestions for the PR.
Don't have strong opinion on this one, I believe there might be situations where you don't want to automatically dump on abort, but if we add it, it might never get used.

So let's simplify and follow your suggestions, if we see use cases or issues we can always add it 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding the timeout, shouldn't that already be covered by the bodyTimeout?
It might look redundant, and to have effect it might require to always set it lower to the bodyTimeout set for the Client/Agent

Comment on lines 34 to 37
if (this.#aborted) {
abort(this.#reason)
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (this.#aborted) {
abort(this.#reason)
return
}
if (this.#aborted) {
abort(this.#reason)
return
}

This can't happen?

lib/interceptor/dump.js Outdated Show resolved Hide resolved
metcoder95 and others added 2 commits May 13, 2024 12:13
Co-authored-by: Robert Nagy <[email protected]>
@metcoder95 metcoder95 requested a review from ronag May 13, 2024 14:54
docs/docs/api/Dispatcher.md 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.

You haven't implemented the timeout? Remove?

@metcoder95
Copy link
Member Author

You haven't implemented the timeout? Remove?

Replied here 😅
#3118 (comment)
Shall we expose it or what do you have in mind for it?

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
@metcoder95 metcoder95 requested a review from ronag May 13, 2024 15:08
lib/interceptor/dump.js Outdated Show resolved Hide resolved
@metcoder95 metcoder95 requested a review from ronag May 15, 2024 07:58
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 106bf1c into main May 15, 2024
36 checks passed
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