Skip to content

perf: deduplicate concurrent model catalog fetches#75

Open
kumarabhirup wants to merge 2 commits into
mainfrom
perf/25-dedup-model-catalog-fetches
Open

perf: deduplicate concurrent model catalog fetches#75
kumarabhirup wants to merge 2 commits into
mainfrom
perf/25-dedup-model-catalog-fetches

Conversation

@kumarabhirup
Copy link
Copy Markdown
Collaborator

Fixes #25

Adds promise deduplication to ensureOpenClawModelsJson so concurrent callers share the same in-flight promise instead of triggering redundant filesystem I/O.

Replace cryptic 'Unauthorized' responses with descriptive messages that
tell the user what went wrong and how to fix it:

- HTTP auth failures now include specific reasons (token_mismatch,
  password_missing, trusted_proxy_untrusted_source, etc.) with
  actionable hints (which env var or config key to check)
- WebSocket upgrade 401s now return JSON with the failure reason
  instead of a bare 'HTTP/1.1 401 Unauthorized'
- Webhook auth failures explain secret mismatch
- assertGatewayAuthConfigured password error now suggests the env var
- gateway URL override error explains what credentials are needed

Closes #33
ensureOpenClawModelsJson is called from many concurrent code paths (model
catalog loader, agent context, image tools, embedded runner) and performs
filesystem I/O (resolve providers → read/write models.json) on every call.

Store the in-flight promise and return it to subsequent callers so only the
first concurrent request does the actual work.  The promise is cleared once
settled so future calls pick up config changes.

Callers that pass explicit config/agentDir overrides bypass the cache to
preserve their custom semantics.
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.

Model catalog fetches are not deduplicated across concurrent requests

1 participant