your-papa/obsidian-Smart2Brain

TimeoutError: Transaction timed out due to inactivity

Opened this issue · 5 comments

What happened?

I am using it with Ollama and "run on your local machine" settings.

Plugin works perfectly on the first run. It indexes the notes, starts up the chat and retrieves the info.
But if I close Obsidian and then start it again, the plugin won't work.

  • The UI freezes and the memory consumption for Obsidian.exe in Windows Task Manager starts growing. It never reaches the limit though, I have 32 GB of RAM.
  • After about ~5 minutes of being unresponsive UI becomes responsive again, but the three dots animation is still going on.
  • I get a message in the dev console: [PAPA] Restored vectorstore from backup and an error message (see below)
  • Memory consumption for Obsidian.exe drops back to ~700 Mb
  • If I try to enter something in the chat, I get a message: "Smart Second Brain is still indexing. Please wait"
  • If I change the plugin settings and launch reindexing manually, or click the "clear plugin data" button, the plugin will work again. But again, only until I close Obsidian.

Obsidian version: 1.5.12
ollama version: 0.1.31 Windows preview
Smart Second Brain version: 1.0.2

Error Statement

plugin:smart-second-brain:448 Uncaught (in promise) a {_e: Error
    at vs (plugin:smart-second-brain:19:658228)
    at new a (plugin:smart-second-brain:23:59…, name: 'AbortError', message: 'TimeoutError Transaction timed out due to inactivity.', inner: DOMException: Transaction timed out due to inactivity.}inner: DOMException: Transaction timed out due to inactivity.code: 23message: "Transaction timed out due to inactivity."name: "TimeoutError"[[Prototype]]: DOMExceptionABORT_ERR: 20DATA_CLONE_ERR: 25DOMSTRING_SIZE_ERR: 2HIERARCHY_REQUEST_ERR: 3INDEX_SIZE_ERR: 1INUSE_ATTRIBUTE_ERR: 10INVALID_ACCESS_ERR: 15INVALID_CHARACTER_ERR: 5INVALID_MODIFICATION_ERR: 13INVALID_NODE_TYPE_ERR: 24INVALID_STATE_ERR: 11NAMESPACE_ERR: 14NETWORK_ERR: 19NOT_FOUND_ERR: 8NOT_SUPPORTED_ERR: 9NO_DATA_ALLOWED_ERR: 6NO_MODIFICATION_ALLOWED_ERR: 7QUOTA_EXCEEDED_ERR: 22SECURITY_ERR: 18SYNTAX_ERR: 12TIMEOUT_ERR: 23TYPE_MISMATCH_ERR: 17URL_MISMATCH_ERR: 21VALIDATION_ERR: 16WRONG_DOCUMENT_ERR: 4code: (...)message: (...)name: (...)constructor: ƒ DOMException()Symbol(Symbol.toStringTag): "DOMException"get code: ƒ code()get message: ƒ message()get name: ƒ name()[[Prototype]]: Objectmessage: "TimeoutError Transaction timed out due to inactivity."name: "AbortError"_e: Error
    at vs (plugin:smart-second-brain:19:658228)
    at new a (plugin:smart-second-brain:23:590)
    at IDBTransaction.eval (plugin:smart-second-brain:25:25855)
    at IDBTransaction.eval (plugin:smart-second-brain:24:5827)stack: "Error\n    at vs (plugin:smart-second-brain:19:658228)\n    at new a (plugin:smart-second-brain:23:590)\n    at IDBTransaction.eval (plugin:smart-second-brain:25:25855)\n    at IDBTransaction.eval (plugin:smart-second-brain:24:5827)"[[Prototype]]: Objectstack: (...)[[Prototype]]: gl
init @ plugin:smart-second-brain:448

Steps to Reproduce

  1. Make sure ollama is running
  2. Install the plugin
  3. Install any of the embedding models (e.g. mxbai-embed-large)
  4. Install chat model (llama2)
  5. Let the plugin do the indexing
  6. Try to retrive the info to make sure it is working
  7. Close Obsidian
  8. Start up Obsidian again
  9. Click "Start Smart Second Brain" button
  10. Wait until the UI unfreezes
  11. Check the dev console to see the error message

Smart Second Brain Version

1.0.2

Debug Info

app.js:1 Obsidian Developer Console
plugin:smart-second-brain:445 [S2B] Initializing second brain
Gen Model: {model: 'llama2', baseUrl: 'http://localhost:11434', temperature: 1, contextWindow: 1748, lcModel: {…}}
Embed Model: {model: 'mxbai-embed-large', baseUrl: 'http://localhost:11434', similarityThreshold: 0.44, k: 100}

More info: in my Obsidian vault, I have 119 documents. However, the console.log says:

[PAPA] Loaded 1402 documents from Obsidian

Which is incorrect.
For the test I've created a new vault with only one markdown document. It was indexed properly and the console said:

[PAPA] Loaded 1 documents from Obsidian

Which is correct.
This new vault doesn't have the issue mentioned in the original post. I can restart Obsidian and use the plugin. But on my main vault with 119 documents, I can't.

More info: after trial and error, I learned that the "TimeoutError" issue occurs only if I have Markdown files with embedded images (using the data:image tag) indexed.

I think document number isn't a sign at all. From their explanation of how this works, documents are like chunked versions of your notes.

Try taking that 1 note you made and make it like 4000 words long. That should cause more than a couple documents to be logged.

I think document number isn't a sign at all. From their explanation of how this works, documents are like chunked versions of your notes.

Try taking that 1 note you made and make it like 4000 words long. That should cause more than a couple documents to be logged.

Yes, document number and note number are different things, I stand corrected. However, the observation about the document number lead me to the source of the problem: if the markdown note contains a large embedded image, it will cause the Timeout error after Obsidian restarts.

I am not sure if it's an issue with the plugin or with ollama itself.

As a local solution, I may need to find a way to ignore documents starting with "image:data", probably.

Interesting that embedded images cause such an error as it's also just text that needs to be embedded. Maybe chunking is the issue.

For now, as you said, it probably makes most sense to just ignore them. Will be implemented in one of the next releases.