Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout settings to HTTP requests #4

Merged
merged 2 commits into from
Dec 1, 2024

Conversation

7shi
Copy link
Contributor

@7shi 7shi commented Dec 1, 2024

This PR adds timeout settings to all HTTP requests made to Obsidian Local REST API to prevent potential freezes when the API becomes unresponsive.

Background

There is a known issue with Obsidian Local REST API where it sometimes does not return a response when encountering errors (see coddingtonbear/obsidian-local-rest-api#139). While there might be other cases where error handling is insufficient in the API, this PR focuses on preventing indefinite freezes by adding proper timeout handling.

Changes

  • Added timeout settings (3, 6) (connect timeout, read timeout) to all HTTP requests
  • Connect timeout: 3 seconds is sufficient for local connections
  • Read timeout: 6 seconds allows enough time for operations while ensuring errors occur before MCP clients disconnect
    • MCP Inspector disconnects after ~10 seconds
    • Claude Desktop App disconnects after ~8 seconds

The client now fails gracefully with timeout errors instead of hanging indefinitely, and errors occur before MCP clients would disconnect.

This PR resolves #3.

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.

Obsidian Rest API starts hanging forever when patch content is called with invalid target
2 participants