Skip to content

Conversation

@KartulUdus
Copy link

@KartulUdus KartulUdus commented Nov 8, 2025

Setting homarr up for the first time, I got a Cannot read properties of undefined (reading online_cpus) error when accessing manage -> tools -> docker.

In my case it was an issue of orphaned running containers where online_cpus were null.
I achieved this feat by removing services from a docker-compose stack while the containers were still running and later restarting the compose stack.

Having exited containers exist should not stop a user from using the Docker tool.

  • Display exited containers in
  • Prevent 'Cannot read properties of undefined (reading online_cpus)' error
  • Fixed exited status container error in docker-table (⨯ TypeError: Cannot read properties of null (reading 'map')

Homarr

Thank you for your contribution. Please ensure that your pull request meets the following pull request:

  • Builds without warnings or errors (pnpm build, autofix with pnpm format:fix)
  • Pull request targets dev branch
  • Commits follow the conventional commits guideline
  • No shorthand variable names are used (eg. x, y, i or any abbrevation)
  • Documentation is up to date. Create a pull request here.

- Add 'orphaned' container state to handle containers with null/undefined cpu_stats.online_cpus
- Display orphaned containers with gray badge in UI
- Prevent 'Cannot read properties of undefined (reading online_cpus)' error
- Add translations for 'orphaned' status in all supported languages
- Containers with invalid stats are now marked as orphaned instead of causing errors
@KartulUdus KartulUdus requested a review from a team as a code owner November 8, 2025 23:30
@deepsource-io
Copy link
Contributor

deepsource-io bot commented Nov 8, 2025

Here's the code health analysis summary for commits 35ca057..74efd0b. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@manuel-rw manuel-rw added the bug Something isn't working label Nov 9, 2025
Comment on lines 93 to 107
return {
id: container.Id,
name: container.Names[0]?.split("/")[1] ?? "Unknown",
state: "orphaned" as ContainerState,
iconUrl:
dbIcons.find((icon) => {
const extractedImage = extractImage(container);
if (!extractedImage) return false;
return icon.name.toLowerCase().includes(extractedImage.toLowerCase());
})?.url ?? null,
cpuUsage: 0,
memoryUsage: 0,
image: container.Image,
ports: container.Ports,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to show "failed containers" as "orphaned"?
When does this catch usually get triggered?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it's not a valid docker container status.
Removed the "orphaned" status and tested these containers to have "exited" status.

Simplified the approach, added safety checks to CPU and memory calculations so it won't fail if cpu_usage, numberOfCpus or memory_stats.usage is null.

exited containers don't have ports either so added a check for no ports in
apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx too

@KartulUdus KartulUdus requested a review from manuel-rw November 10, 2025 10:46
.catch(() => ({
cpu_stats: { online_cpus: 0, cpu_usage: { total_usage: 0 }, system_cpu_usage: 0 },
memory_stats: { usage: 0 },
} as ContainerStats));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use satisfies here if possible?

@tristan-pflegeabc
Copy link

i was also running into this bug after updating my images and rebooting, docker intergration stopped working, searched hours, debugged the docker api, then found out it was an orphaned container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants