-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Unraid OS Version:
7.2.2 (Latest)
Are you using a reverse proxy?
No - Issue tested with direct access to server.
Pre-submission Checklist
- I have verified that my Unraid OS is up to date
- I have tested this issue by accessing my server directly (not through a reverse proxy)
- This is not an Unraid Connect related issue (if it is, please submit via the support form instead)
Issue Description
The Docker service caches container state for 60 seconds (CACHE_TTL_SECONDS = 60 in docker.service.ts). While this cache is
correctly invalidated after GraphQL mutations (start/stop), it is NOT invalidated when containers are started/stopped from
external sources (Unraid WebUI, Docker CLI, etc.).
This causes third-party apps polling the GraphQL API to show stale container state for up to 60 seconds when users manage
containers from sources other than the API.
Steps to Reproduce
- Query Docker containers via GraphQL API (e.g., using
docker { containers { ... } }) - Stop a running container using Unraid WebUI (not the GraphQL API)
- Query Docker containers again via GraphQL API within 60 seconds
- Observe that the API still returns the container as "running"
Expected Behavior
Container state should reflect actual Docker state within a reasonable time (5-10 seconds maximum).
Actual Behavior
Container state is cached for up to 60 seconds, returning stale data when containers are managed from sources other than the
GraphQL API (WebUI, CLI, etc.).
Additional Context
Technical Details:
File: api/src/unraid-api/graph/resolvers/docker/docker.service.ts
The cache is cleared after API mutations:
public async start(id: string): Promise<DockerContainer> {
// ... start container logic
await this.clearContainerCache(); // ✅ Cache cleared here
return this.getContainer(id);
}But there's no mechanism to invalidate cache when Docker events occur externally.
Suggested Solutions:
- Reduce cache TTL to 5-10 seconds for container state queries
- Listen to Docker events (
docker events) and invalidate cache on container state changes - Add GraphQL subscription for real-time container state updates (similar to array subscriptions)
Discovered while developing a third-party mobile app that polls the GraphQL API for Docker container status."