Skip to content

Conversation

@howl0893
Copy link
Contributor

@howl0893 howl0893 commented Sep 4, 2025

Backend support for BrainDriveChat plugin enhancements

  • Web search integration via SearXNG endpoints
  • Document processing and management system
  • AI generation cancellation with request tracking
  • Enhanced persona and conversation management
  • Request tracker service for AI provider management

- Web search integration via SearXNG endpoints
- Document processing and management system
- AI generation cancellation with request tracking
- Enhanced persona and conversation management
- Request tracker service for AI provider management
@DJJones66
Copy link
Contributor

Issue: RuntimeError on Backend Startup - No Running Event Loop

Problem Description:
The backend fails to start with the following error when running the application:

RuntimeError: no running event loop

Stack Trace:

File "/home/hacker/BrainDriveDev/BrainDrive/backend/app/services/request_tracker.py", line 147, in <module>
    request_tracker = RequestTracker()
File "/home/hacker/BrainDriveDev/BrainDrive/backend/app/services/request_tracker.py", line 20, in __init__
    self._start_cleanup()
File "/home/hacker/BrainDriveDev/BrainDrive/backend/app/services/request_tracker.py", line 25, in _start_cleanup
    self._cleanup_task = asyncio.create_task(self._cleanup_loop())
RuntimeError: no running event loop

Root Cause:
The RequestTracker class is instantiated as a global singleton at module import time (line 147). During initialization, it attempts to create an asyncio task via asyncio.create_task() in the _start_cleanup() method. However, at module import time, there is no running event loop, which causes the RuntimeError.

Impact:
This prevents the backend from starting entirely, making the application unusable.

@howl0893
Copy link
Contributor Author

howl0893 commented Sep 4, 2025

Interesting, this starts up fine on a clean version of the branch for me...
I won't have time to properly address this until next week. So, just removed the request tracker for now. The plugin AbortController will still cancel messages from streaming to the frontend.

@DJJones66
Copy link
Contributor

I did attempt on a second system. Do you know if this needs additional requirements?

@howl0893
Copy link
Contributor Author

howl0893 commented Sep 4, 2025

I don't believe so.
Do you experience any other issues with it removed?

@DJJones66
Copy link
Contributor

Like in searng.py there is bs4, I was hoping for a quick review between doing other things so haven't really delved into things yet

@howl0893
Copy link
Contributor Author

howl0893 commented Sep 4, 2025

Ah, I accidentally stashed my requirements.txt, but I did add that dependency. I don't think there are any others but I will have to double check.
No problem. Hopefully the request_tracker removal fixed things - not sure that was ready to be pushed anyway.

@DJJones66 DJJones66 merged commit 0d5e595 into BrainDriveAI:main Sep 9, 2025
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.

2 participants