Hi everyone,
I’m currently exploring the codebase as a prospective contributor and while reviewing packages/lib/services/ResourceService.ts, I noticed that indexNoteResources() appears to use a boolean flag (e.g., isIndexing_) to prevent concurrent execution.
From my understanding, the current pattern is roughly:
if (this.isIndexing_) return;
this.isIndexing_ = true;
// async work
this.isIndexing_ = false;
I was wondering whether this could potentially allow overlapping executions under certain asynchronous timing scenarios, especially if multiple calls are triggered very close together.
Would it make sense to replace this pattern with a lightweight async mutex abstraction to guarantee proper mutual exclusion? The idea would be:
- Ensure safe async mutual exclusion
- Avoid possible race conditions
- Provide a reusable utility for other services if needed
Before attempting any changes, I wanted to ask:
- Is this an intentional design decision?
- Has concurrency handling here been discussed before?
- Would maintainers be open to a small PR introducing an async mutex utility for this case?
I’m happy to investigate further or prototype a minimal implementation if this aligns with the project direction. Thanks!