Skip to content

fix(sdk): validate timeout before best-effort swallow in connections() (TS + Python)#120

Merged
rapguit merged 2 commits into
mainfrom
fix/issue-118-connections-hardening
Jul 24, 2026
Merged

fix(sdk): validate timeout before best-effort swallow in connections() (TS + Python)#120
rapguit merged 2 commits into
mainfrom
fix/issue-118-connections-hardening

Conversation

@rapguit

@rapguit rapguit commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Two small hardening follow-ups to @AndreLFSMartins's timeout/cancellation work in #49 — picking these up as noted in #118 to finish the set, applied to the current code.

  • TS (packages/core/src/session.ts): connections() now resolves and validates the effective timeout before the best-effort try (same shape as close()), so an invalid timeout (0, negative, NaN, Infinity) rejects instead of being silently swallowed into the cached-list fallback. No request is issued for invalid values.
  • Python (packages/python/src/codespar/_async_session.py): connections() suppresses TimeoutError alongside ApiError on the best-effort read (parity with close() and the TS client). Unrelated exceptions keep propagating. The sync client delegates to the async implementation, so one edit covers both.

Tests added for both sides (invalid-timeout fail-fast + cached-fallback regression in Vitest; timeout→cache, empty-cache, and unrelated-error-propagates in pytest).

Behavior-preserving for valid inputs.

Closes #118

🤖 Generated with Claude Code

…) (TS + Python)

- TS: connections() now validates the effective timeout before the
  catch-all fallback (parity with close()), so an invalid value (0,
  negative, NaN, Infinity) surfaces instead of silently returning the
  cached list.
- Python: async connections() suppresses TimeoutError alongside
  ApiError on the best-effort read (parity with close() and the TS
  client); unrelated errors keep propagating.

Behavior-preserving for valid inputs.

Closes #118

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rapguit
rapguit merged commit 08d2cc1 into main Jul 24, 2026
10 checks passed
@rapguit
rapguit deleted the fix/issue-118-connections-hardening branch July 24, 2026 23:05
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.

SDK: two small hardening follow-ups from the #49 review

1 participant