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

Obsidian Rest API starts hanging forever when patch content is called with invalid target #3

Closed
MarkusPfundstein opened this issue Dec 1, 2024 · 4 comments · Fixed by #4

Comments

@MarkusPfundstein
Copy link
Owner

When the tool patch_content is called , the ToolHandler calls the URL PATCH /vault/{filename}.

When the Obsidian REST API can't find the target, it throws a PatchFailed error. It seems as if this error is never returned to the client. After a while, MCP throws a timeout error and Claude tells us that it can't do it.

This is annoying but not breaking. However, the Obsidian plugin also becomes totally unresponsive afterwards. Each call then timeouts, also if done via curl (so not related to MCP).

No idea yet how to fix it. There is an issue reported here that might resolve it? https://github.com/coddingtonbear/obsidian-local-rest-api/pull/139/files

@7shi
Copy link
Contributor

7shi commented Dec 1, 2024

While PR (coddingtonbear/obsidian-local-rest-api#139) resolves the hanging issue in patch_content, but there might be other areas where error handling is insufficient.

So, I've added timeout in PR #4 to prevent hanging forever.

While testing, I found that:

  • MCP Inspector disconnects from MCP server after ~10 seconds
  • Claude Desktop App disconnects after ~8 seconds

Based on these observations, I set the timeout values to:

  • Connect timeout: 3 seconds
  • Read timeout: 6 seconds

This ensures that the client receives timeout errors before MCP clients force a disconnect.

@MarkusPfundstein
Copy link
Owner Author

love it

@7shi
Copy link
Contributor

7shi commented Dec 6, 2024

While investigating the timeout settings (trying different values to determine the (3,6) parameters), I realized that this issue might be reproducible with a simple wait operation without any actual requests.

I created a minimal reproduction case that simply waits for a specified number of seconds. While looking into reporting this, I noticed that @MarkusPfundstein had already created the issue: modelcontextprotocol/python-sdk#88

The problem occurs with this simple pattern:

  1. Long-running operation (> 8-10 seconds)
  2. Server successfully returns results
  3. Server crashes afterwards, preventing further requests

I've documented my findings in detail there.

@MarkusPfundstein
Copy link
Owner Author

Great work @7shi . Lets see what Anthropic reponds

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 a pull request may close this issue.

2 participants