Skip to content

Comments

fix(gateway): suppress AbortError during config reload#2066

Closed
Glucksberg wants to merge 4 commits intoopenclaw:mainfrom
Glucksberg:fix/unhandled-fetch-rejection-2034
Closed

fix(gateway): suppress AbortError during config reload#2066
Glucksberg wants to merge 4 commits intoopenclaw:mainfrom
Glucksberg:fix/unhandled-fetch-rejection-2034

Conversation

@Glucksberg
Copy link
Contributor

Summary

Fixes gateway crashes during config reload by suppressing AbortError in the unhandled rejection handler.

  • Add isAbortError() to detect AbortError exceptions (intentional cancellations)
  • Add isTransientNetworkError() to detect temporary network failures (ECONNRESET, ETIMEDOUT, etc.)
  • Suppress both error types in installUnhandledRejectionHandler() with appropriate logging
  • Add comprehensive tests for all new functionality

Root Cause

During config reload, the gateway receives SIGUSR1 and calls server.close(), which aborts in-flight network requests. These AbortErrors were previously treated as fatal and caused process.exit(1). Now they are logged as warnings and suppressed.

Changes

src/infra/unhandled-rejections.ts:

  • isAbortError(err) - detects errors with name "AbortError" or message "This operation was aborted"
  • isTransientNetworkError(err) - detects 14 transient network error codes plus "fetch failed" TypeError
  • Updated installUnhandledRejectionHandler() to suppress both error types

src/infra/unhandled-rejections.test.ts:

  • 19 tests covering all edge cases for isAbortError and isTransientNetworkError

Test plan

  • pnpm lint passes
  • pnpm build passes
  • pnpm vitest run src/infra/unhandled-rejections.test.ts - all 19 tests pass
  • Manual verification: AbortError during shutdown is logged as warning, not fatal

Closes #1997

🤖 Generated with Claude Code

Glucksberg and others added 4 commits January 25, 2026 19:42
When block streaming succeeds, final replies are dropped but TTS was only
applied to final replies. Fix by accumulating block text during streaming
and generating TTS-only audio after streaming completes.

Also:
- Change truncate vs skip behavior when summary OFF (now truncates)
- Align TTS limits with Telegram max (4096 chars)
- Improve /tts command help messages with examples
- Add newline separator between accumulated blocks
- Add value/label support for command arg choices
- TTS menu now shows descriptive title listing each action
- Capitalize button labels (On, Off, Status, etc.)
- Update Telegram, Discord, and Slack handlers to use labels

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add isAbortError detection to the unhandled rejection handler to prevent
gateway crashes when AbortError is thrown during graceful shutdown.

Also add isTransientNetworkError to handle "fetch failed" TypeError and
other transient network errors (ECONNRESET, ETIMEDOUT, ENOTFOUND, etc.)
as non-fatal. These are temporary connectivity issues that should be
logged but shouldn't crash the gateway.

During config reload, the gateway receives SIGUSR1 and calls server.close(),
which aborts in-flight network requests. AbortErrors and transient network
errors are now logged as warnings and suppressed.

Closes openclaw#1997
Closes openclaw#2034

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@Glucksberg
Copy link
Contributor Author

This PR also fixes #2034 (Unhandled promise rejection - fetch failed crashes gateway).

The isTransientNetworkError() function handles the exact error reported in #2034:

  • TypeError: fetch failed from Node's native fetch (undici)
  • Transient network codes: ECONNRESET, ENOTFOUND, ETIMEDOUT, etc.

These errors are now logged as non-fatal instead of crashing the gateway.

@ShunsukeHayashi

This comment was marked as spam.

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram labels Jan 26, 2026
@Glucksberg
Copy link
Contributor Author

Closing: superseded by #2451 which contains only the unhandled-rejections fix without TTS changes.

@Glucksberg Glucksberg closed this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway crashes on config reload due to unhandled AbortError

2 participants