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

log all QNetworkReply error messages at debug level #3732

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

levkropp
Copy link
Contributor

@levkropp levkropp commented Oct 15, 2024

The enum for timeouts in Qt's networking library is QNetworkReply::TimeoutError. Different logs are printed at debug, warning, and error levels.

MULTI-1529

@levkropp levkropp force-pushed the log-network-errors branch 2 times, most recently from c011839 to ad458a5 Compare October 16, 2024 21:16
@levkropp levkropp marked this pull request as ready for review October 17, 2024 14:44
@levkropp levkropp linked an issue Nov 6, 2024 that may be closed by this pull request
@levkropp levkropp marked this pull request as draft November 19, 2024 17:31
@levkropp levkropp marked this pull request as ready for review November 19, 2024 17:31
Copy link
Contributor

@sharder996 sharder996 left a comment

Choose a reason for hiding this comment

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

Think we could add or modify some unit tests to assert the different log levels?

src/network/url_downloader.cpp Outdated Show resolved Hide resolved
@levkropp levkropp force-pushed the log-network-errors branch 4 times, most recently from 5d58224 to 770f789 Compare November 22, 2024 00:34
Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

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

Thanks Lev. I have a few questions below.

// Log the original error message at debug level
mpl::log(mpl::Level::debug,
category,
fmt::format("Qt error {}: {}", static_cast<int>(error_code), error_string));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you aware of mp::utils::qenum_to_string?

fmt::format("Qt error {}: {}", static_cast<int>(error_code), error_string));

const bool is_timeout_error = (error_code == QNetworkReply::TimeoutError);
const auto msg = is_timeout_error ? "Network timeout" : error_string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need to replace Qt's timeout message with "Network timeout"?


if (is_timeout_error && download_timeout.isActive())
{
mpl::log(mpl::Level::debug, category, "Timeout error detected but download_timeout is still active");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this indicate an error in our logic? Or in what circumstances is it expected to occur?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The line used to be
const auto msg = download_timeout.isActive() ? reply->errorString().toStdString() : "Network timeout";
So this line is to check if TimeoutErrors happen even when download_timeout.isActive() is true to potentially shed some light on the "instant timeouts" issue and see if its related to QTimer

Note however that the "timeouts" we are getting in #3662 are from us calling abort() which throw an OperationCanceledError with "Operation canceled" as the error string.
https://doc.qt.io/qt-6/qnetworkreply.html#NetworkError-enum
So this is irrelevant for resolving that issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be a warning though?

Copy link
Contributor Author

@levkropp levkropp Nov 22, 2024

Choose a reason for hiding this comment

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

Should this be a warning though?

I guess it can be at error level, but this should never be triggered by an OperationCanceledError and doesn't have any impact on the rest of the error handling which is why I originally put it as debug

sharder996
sharder996 previously approved these changes Nov 22, 2024
Copy link
Contributor

@sharder996 sharder996 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 no more comments. Thanks @levkropp

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.87%. Comparing base (d7e3075) to head (cc8d248).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3732   +/-   ##
=======================================
  Coverage   88.86%   88.87%           
=======================================
  Files         256      256           
  Lines       14569    14579   +10     
=======================================
+ Hits        12947    12957   +10     
  Misses       1622     1622           

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


🚨 Try these New Features:

@levkropp levkropp force-pushed the log-network-errors branch 4 times, most recently from e11c6be to 027d372 Compare November 22, 2024 18:09
Comment on lines 113 to 117

if (download_timeout.isActive())
{
mpl::log(mpl::Level::debug, category, "download_timeout is still active");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (download_timeout.isActive())
{
mpl::log(mpl::Level::debug, category, "download_timeout is still active");
}
mpl::log(mpl::Level::debug, category, fmt::format("download_timeout is {}active", download_timeout.isActive() ? "" : "in"));

ricab
ricab previously approved these changes Nov 22, 2024
Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

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

I added a final suggestion, but it looks good to me now. Thanks!

@ricab ricab requested a review from sharder996 November 22, 2024 18:16
@levkropp levkropp force-pushed the log-network-errors branch 2 times, most recently from 079cb01 to aae279b Compare November 22, 2024 18:58
sharder996
sharder996 previously approved these changes Nov 22, 2024
@sharder996 sharder996 enabled auto-merge November 22, 2024 19:12
@sharder996 sharder996 added this pull request to the merge queue Nov 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Nov 22, 2024
@sharder996
Copy link
Contributor

sharder996 commented Nov 22, 2024

@levkropp Merge conflicts

@sharder996 sharder996 enabled auto-merge November 22, 2024 22:24
@sharder996 sharder996 added this pull request to the merge queue Nov 22, 2024
Merged via the queue into main with commit 2f0097b Nov 23, 2024
14 checks passed
@sharder996 sharder996 deleted the log-network-errors branch November 23, 2024 00:11
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.

Network errors from Qt are overridden with "Network timeout"
3 participants