fix(feishu): add transient network retry for message send operations#428
Open
0xsegfaulted wants to merge 1 commit intochenhg5:mainfrom
Open
fix(feishu): add transient network retry for message send operations#4280xsegfaulted wants to merge 1 commit intochenhg5:mainfrom
0xsegfaulted wants to merge 1 commit intochenhg5:mainfrom
Conversation
When Feishu WebSocket connections experience rapid resets, HTTP API calls for sending messages also fail with transient network errors (EOF, connection reset, timeout). Previously these errors were not retried, causing messages to be silently lost. Add withTransientRetry wrapper with exponential backoff + jitter (500ms→1s→2s, max 3 retries, +25% jitter) around all Feishu API calls: reply, create, patch, delete, upload image/file/audio, and preview. Transient detection uses typed syscall checks (ECONNRESET, EPIPE), net.Error timeout, io.EOF, and string matching as fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chenhg5
approved these changes
Apr 3, 2026
Owner
chenhg5
left a comment
There was a problem hiding this comment.
LGTM. Well-structured transient network retry implementation for Feishu.
Review summary:
- ✅
withTransientRetrywrapper with exponential backoff + jitter (500ms→1s→2s, max 3 retries, +25% jitter) - ✅ Comprehensive transient error detection: syscall checks (ECONNRESET, EPIPE), net.Error timeout, io.EOF, string-matching fallback
- ✅ Layered design: transient retry (outer) wraps token refresh retry (inner)
- ✅ Non-transient errors (API errors, rate limits) are not retried
- ✅ All 8 Feishu API call sites wrapped
- ✅ Comprehensive test coverage: 16 error type subtests, integration tests with httptest + connection hijacking
- ✅ CI passes (lint, unit-test, smoke-test, regression-test, performance-test)
Great contribution! Thanks for the detailed PR description and comprehensive tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
withTransientRetrywrapper with exponential backoff + jitter (500ms→1s→2s, max 3 retries, +25% jitter) for all Feishu HTTP API callsECONNRESET,EPIPE),net.Errortimeout,io.EOF, and string-matching fallbackProblem
When Feishu WebSocket connections experience rapid resets (every 20-40s for ~3 minutes), HTTP API calls for sending messages also fail with transient network errors (
EOF,connection reset by peer,i/o timeout). Previously these errors were not retried — only token refresh retry (code 99991663) existed — causing messages to be silently lost with delays of 5-25 minutes.Design
Test plan
TestIsTransientError— 16 error type subtests including syscall, net.Error, EOF, string matching, and negative casesTestWithTransientRetry_*— 5 unit tests: success, retry-then-succeed, non-transient passthrough, max retry exhaustion, context cancellationTestReplyRetriesOnTransientNetworkError— integration test with httptest + connection hijackingTestCreateMessageRetriesOnTransientNetworkError— integration testTestPatchMessageRetriesOnTransientError— integration testTestReplyDoesNotRetryOnNonTransientAPIError— integration testTestReplyTransientRetryThenTokenRefresh— validates both retry layers working togetherTestWithTransientRetry_BackoffTiming— verifies backoff timing is reasonablego build ./...clean🤖 Generated with Claude Code