Skip to content

Don't log errors when connect fails due to a user error#6665

Draft
fhanau wants to merge 1 commit intomainfrom
felix/042426-connect-warnings
Draft

Don't log errors when connect fails due to a user error#6665
fhanau wants to merge 1 commit intomainfrom
felix/042426-connect-warnings

Conversation

@fhanau
Copy link
Copy Markdown
Contributor

@fhanau fhanau commented Apr 24, 2026

This should address the logs we're getting when connect is invoked without a connect handler being present

================

Not sure if this is the right approach here – might be better to change how exception handling works for connect? I have some tests available locally, but they only reproduce the issue, they're not able to check for the error not being logged.

This should address the logs we're getting when connect is invoked without a
connect handler being present
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

This PR suppresses LOG_ERROR_PERIODICALLY for socket proxy errors that are tagged as user errors (e.g., missing connect() handler), in both handleProxyStatus overloads.

  1. Stale comment (low): The comment at line 436-438 only mentions "disconnected exception" but the filter now also covers user errors. Should be updated to reflect the new condition.
  2. Missing DISCONNECTED filter in second overload (low): The first overload filters both DISCONNECTED and EXCEPTION_IS_USER_ERROR, but the second overload (line 484) only filters EXCEPTION_IS_USER_ERROR. This is a pre-existing gap but since you're touching this code, it might be worth aligning both overloads for consistency.

Comment on lines 436 to 438
// Let's not log errors when we have a disconnected exception.
// If we don't filter this out, whenever connect() fails, we'll
// have noisy errors even though the user catches the error on JS side.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment only describes the DISCONNECTED filter but should also mention the EXCEPTION_IS_USER_ERROR check you're adding:

Suggested change
// Let's not log errors when we have a disconnected exception.
// If we don't filter this out, whenever connect() fails, we'll
// have noisy errors even though the user catches the error on JS side.
// Let's not log errors when we have a disconnected exception or a user error.
// If we don't filter this out, whenever connect() fails, we'll
// have noisy errors even though the user catches the error on JS side.

Comment on lines +485 to +487
if (e.getDetail(jsg::EXCEPTION_IS_USER_ERROR) == kj::none) {
LOG_ERROR_PERIODICALLY("Socket proxy disconnected abruptly", e);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The first handleProxyStatus overload filters both DISCONNECTED and EXCEPTION_IS_USER_ERROR, but this one only filters EXCEPTION_IS_USER_ERROR. Should the DISCONNECTED check be added here too for consistency?

Suggested change
if (e.getDetail(jsg::EXCEPTION_IS_USER_ERROR) == kj::none) {
LOG_ERROR_PERIODICALLY("Socket proxy disconnected abruptly", e);
}
if (e.getType() != kj::Exception::Type::DISCONNECTED &&
e.getDetail(jsg::EXCEPTION_IS_USER_ERROR) == kj::none) {
LOG_ERROR_PERIODICALLY("Socket proxy disconnected abruptly", e);
}

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 24, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR suppresses LOG_ERROR_PERIODICALLY for socket proxy errors tagged as user errors (e.g., missing connect() handler), in both handleProxyStatus overloads.

Two low-severity items posted as inline suggestions on the PR:

  1. Stale comment (line 436-438): The comment only mentions "disconnected exception" but should now also mention the EXCEPTION_IS_USER_ERROR filter.
  2. Missing DISCONNECTED filter in second overload (line 485): The first overload filters both DISCONNECTED and EXCEPTION_IS_USER_ERROR, but the second only filters EXCEPTION_IS_USER_ERROR. Pre-existing gap, but worth aligning since the code is being touched.

github run

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.51%. Comparing base (49ee782) to head (aeba0f5).

Files with missing lines Patch % Lines
src/workerd/api/sockets.c++ 0.00% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6665      +/-   ##
==========================================
- Coverage   66.53%   66.51%   -0.03%     
==========================================
  Files         405      405              
  Lines      115964   115967       +3     
  Branches    19407    19409       +2     
==========================================
- Hits        77153    77131      -22     
- Misses      27229    27255      +26     
+ Partials    11582    11581       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants