Skip to content

Realtime RC - Check HTTP status before listening and retrying #4121

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

Merged
merged 6 commits into from
Sep 21, 2022

Conversation

qdpham13
Copy link
Contributor

@qdpham13 qdpham13 commented Sep 20, 2022

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 20, 2022

Coverage Report 1

Affected Products

  • firebase-config

    Overall coverage changed from 77.45% (5bba4bc) to 80.00% (504b9db) by +2.55%.

    FilenameBase (5bba4bc)Merge (504b9db)Diff
    ConfigAutoFetch.java89.13%88.64%-0.49%
    ConfigRealtimeHttpClient.java0.00%31.58%+31.58%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/X78l47HwLf.html

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2022

Unit Test Results

1 226 tests  +4   1 226 ✔️ +4   2m 11s ⏱️ -28s
     62 suites ±0          0 💤 ±0 
     62 files   ±0          0 ±0 

Results for commit 0c96b00. ± Comparison against base commit 5bba4bc.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 20, 2022

Size Report 1

Affected Products

  • firebase-config

    TypeBase (5bba4bc)Merge (504b9db)Diff
    aar83.1 kB83.4 kB+262 B (+0.3%)
    apk (aggressive)119 kB119 kB+124 B (+0.1%)
    apk (release)743 kB743 kB+20 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/AWu8SraH3T.html

@qdpham13 qdpham13 requested a review from danasilver September 20, 2022 23:05
if (!canMakeHttpStreamConnection()) {
return;
}

int responseCode = 200;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would just leave this unset here (i.e int responseCode;) to ensure HTTP_OK means we really did get a response from the server

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did this originally because of the edge case where the client isn't able to make a connection with the server(due to an exception or no connection) and doesn't get a status code back but initialized it to 0 instead and added a check for 0 too.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about checking responseCode == null or just !responseCode to indicate no response code was set (the connection wasn't made)? 0 is confusing since it's not a valid value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it to check for responseCode == null

|| statusCode == HttpURLConnection.HTTP_BAD_GATEWAY
|| statusCode == HttpURLConnection.HTTP_UNAVAILABLE
|| statusCode == HttpURLConnection.HTTP_GATEWAY_TIMEOUT
|| statusCode == HttpURLConnection.HTTP_OK;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here why we're retrying when we got an OK response since "retry" sounds like error handling logic. I'd even consider changing the condition below to split the success case out to avoid confusion: if (isStatusCodeRetryable(responseCode) || responseCode == HTTP_OK) { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split the http_ok code out of isStatusCodeRetryable method

@qdpham13 qdpham13 merged commit dffa923 into realtime-rc-merge Sep 21, 2022
@qdpham13 qdpham13 deleted the realtime-rc-http-check branch September 21, 2022 23:03
@firebase firebase locked and limited conversation to collaborators Oct 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants