mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(heap): report again at 95 % and leave a report on an out-of-memory exit
The pressure report re-armed only after the heap fell under 70 % and half an hour passed, so a heap that climbed to its limit soon after an 85 % report died with only that older report on record. A 95 % tier now writes the same report at once, whatever the cooldown, and re-arms under 85 %. The image sets NODE_OPTIONS so Node writes its diagnostic report to stderr when the heap runs out, with environment variables and network interfaces excluded. The heap-diagnostics and scaling docs say how to keep the flags when overriding NODE_OPTIONS. Heap figures share one megabytes helper with the support report.
This commit is contained in:
1 parent
3cf67d05f9
commit
b79bd8370d
7 files changed
+101
-14
No files matched your search
@@ -14,9 +14,14 @@ import { getHeapStatistics } from "node:v8";
|
||||
/** Below this, the heap is flagged. Between the 1g (524) and 1536m (792) heaps. */
|
||||
export const LOW_HEAP_LIMIT_MB = 700;
|
||||
|
||||
/** Bytes as whole megabytes (MiB), the unit every heap figure is shown in. */
|
||||
export function megabytes(bytes: number): number {
|
||||
return Math.round(bytes / 1024 / 1024);
|
||||
}
|
||||
|
||||
/** V8's heap limit for this process, in megabytes. */
|
||||
export function heapLimitMb(): number {
|
||||
return Math.round(getHeapStatistics().heap_size_limit / 1024 / 1024);
|
||||
return megabytes(getHeapStatistics().heap_size_limit);
|
||||
}
|
||||
|
||||
export function isHeapLimitLow(limitMb: number): boolean {
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
heapLimitMb,
|
||||
isHeapLimitLow,
|
||||
lowHeapLimitAdvice,
|
||||
megabytes,
|
||||
} from "@/lib/support/heap-limit";
|
||||
import { shouldEmitSecureCookie } from "@/lib/auth/secure-cookie";
|
||||
import { isOidcConfigured, isOidcOnly } from "@/lib/auth/oidc";
|
||||
@@ -692,8 +693,8 @@ function or(value: string | number | null | undefined, fallback = "unknown") {
|
||||
: String(value);
|
||||
}
|
||||
|
||||
function megabytes(bytes: number | null): string {
|
||||
return bytes === null ? "unknown" : `${Math.round(bytes / 1024 / 1024)} MB`;
|
||||
function sizeLine(bytes: number | null): string {
|
||||
return bytes === null ? "unknown" : `${megabytes(bytes)} MB`;
|
||||
}
|
||||
|
||||
function runLine(run: QueueRunFact | null): string {
|
||||
@@ -741,7 +742,7 @@ export function renderSupportReport(facts: SupportReportFacts): string {
|
||||
section("Database");
|
||||
row("PostgreSQL", facts.database.version);
|
||||
row("Server time zone", facts.database.timezone);
|
||||
row("Size", megabytes(facts.database.sizeBytes));
|
||||
row("Size", sizeLine(facts.database.sizeBytes));
|
||||
row(
|
||||
"Last migration",
|
||||
facts.database.lastMigration
|
||||
|
||||
Reference in new issue
Block a user