fix(infra): handle Slack SDK empty-message wrapper and undefined rejection reasons#1905
Open
BingqingLyu wants to merge 1 commit into
Open
fix(infra): handle Slack SDK empty-message wrapper and undefined rejection reasons#1905BingqingLyu wants to merge 1 commit into
BingqingLyu wants to merge 1 commit into
Conversation
…ction reasons The @slack/web-api SDK wraps network errors via requestErrorWithOriginal() under the code slack_webapi_request_error. When the original error has an empty message (observed during macOS sleep/wake and prolonged network outages), the resulting wrapper message is just 'A request error occurred: ' — which matches no existing transient snippet or code, causing process.exit(1) and gateway crash loops. Additionally, @slack/socket-mode can call reject() without an argument during WebSocket TLS errors, producing an undefined rejection reason that falls through all classification checks to process.exit(1). Changes: 1. Recognize slack_webapi_request_error code + request wrapper message pattern as inherently transient, even when the inner error has no identifiable code 2. Treat undefined/null rejection reasons as non-fatal with a warning log Fixes openclaw#23169, openclaw#21082 Relates to openclaw#43689
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.
Problem
The
@slack/web-apiSDK wraps all network errors viarequestErrorWithOriginal()under the codeslack_webapi_request_error. The existing transient detection (added in openclaw#24582 and openclaw#23787) handles the common case where the wrapped error message contains a recognizable network code (e.g.,ENOTFOUND,ENETUNREACH).However, two edge cases still crash the gateway:
1. Empty original message (crash loop on network outage)
During macOS sleep/wake or prolonged connectivity drops, the Slack SDK wraps a network error whose
.messageis empty, producing:This matches no existing transient snippet or code →
process.exit(1)→ launchd restart → crash loop.Observed in production: Apr 2, 2026 — 160+ restarts in 20 minutes on a macOS host, causing ephemeral port exhaustion and total network death.
2.
undefinedrejection reason (WebSocket TLS errors)@slack/socket-modecan callreject()without an argument during WebSocket TLS disconnect errors. The resultingundefinedreason falls through all classification checks (AbortError, fatal, config, transient) toprocess.exit(1).Fix
Two complementary changes:
isTransientNetworkError(): Recognizeslack_webapi_request_errorcode + request wrapper message pattern (/^A request error occurred:/ior empty) as inherently transient, even when the inner error has no identifiable network code. The guard ensures genuine API errors (e.g.,invalid_auth) are NOT suppressed.installUnhandledRejectionHandler(): Treatundefined/nullrejection reasons as non-fatal with a distinct warning log ("Non-fatal unhandled rejection (undefined reason, continuing)"), instead of crashing.Test coverage
invalid_auth) → still fatal ✅undefinedrejection → non-fatal ✅nullrejection → non-fatal ✅All 55 tests pass.
Related issues
Fixes openclaw#23169 (closed as stale, not fixed — 4 users reported the same crash)
Fixes openclaw#21082 (closed as stale, not fixed — 3 additional reproductions in comments)
Relates to openclaw#43689 (
undefinedrejection variant, still open)