Skip to content

Commit

Permalink
Don't Store Image Response bodies for Network and Network Chart plugi…
Browse files Browse the repository at this point in the history
…n if there is no flipper connection

Summary:
Context
=
I am creating a flipper plugin to track and show network requests in a waterfall display to help IG App developers

See this [GSD](https://www.internalfb.com/gsd/316319693088236/791974585995443/list?t=189784262) for more context

This Diff
=
As the title indicates, this diff strips response bodies if there's no flipper connection in Network and IGNetworkingBehavior plugins. This is to reduce the amount of memory used by the plugin and prevent OOM issues for debug builds for developers not using flipper.

Reviewed By: pfarcasanu

Differential Revision: D60175106

fbshipit-source-id: 07d1895b6da15fdca70719606f4ef46ef0b02688
  • Loading branch information
Kareem Trevor DaCosta authored and facebook-github-bot committed Jul 29, 2024
1 parent 5f4f25f commit b9b25e2
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void reportResponse(final ResponseInfo responseInfo) {
new ErrorReportingRunnable(getConnection()) {
@Override
protected void runOrThrow() throws Exception {
if (shouldStripResponseBody(responseInfo)) {
if (shouldStripResponseBody(responseInfo, isConnected())) {
responseInfo.body = null;
}

Expand Down Expand Up @@ -188,7 +188,11 @@ public static FlipperArray toFlipperObject(List<Header> headers) {
return list.build();
}

public static boolean shouldStripResponseBody(ResponseInfo responseInfo) {
public static boolean shouldStripResponseBody(ResponseInfo responseInfo, boolean isConnected) {
if (!isConnected) {
return true;
}

final Header contentType = responseInfo.getFirstHeader("content-type");
if (contentType == null) {
return false;
Expand Down

0 comments on commit b9b25e2

Please sign in to comment.