mirror of
https://github.com/zadam/trilium.git
synced 2026-09-14 11:06:04 +05:00
Two defects in the docker healthcheck, in one module because the second rewrote the file the first touches. The probe passed `timeout: 2000` to http.request, which only arms the socket idle timer and emits a "timeout" event. Nothing listened for it and nothing destroyed the request, so the option never had any effect: against a server that completes the TCP handshake and then goes quiet, the probe waited without end. That is the exact failure a healthcheck exists to catch, and it was the one case the probe could not report. Docker's own 30 s --timeout, which no Dockerfile overrides, was all that ended these attempts, each of them pinning a node process for the full 30 s first. Handle the event: log the deadline, destroy the request, report unhealthy. The bundle was 3 MB because docker_healthcheck.ts imported config.ts, which reaches @triliumnext/core for envToBoolean and stringToInt. That import is a namespace re-export, so the namespace object keeps every export of utils/index.ts live, and with it sanitize-html, cheerio, parse5, domino, mime-db and iconv-lite. Weight was not the whole problem: loading that chain also created the data directory, wrote a config sample when none existed, and ran the process.exit(1) in resource_dir.ts, so the verdict depended on filesystem layout rather than on the server. No bundler setting removes that. Marking both packages sideEffects-free still left 5.36 MB, because the chain is genuinely reachable and genuinely side-effectful. resolveHealthcheckTarget() reads the same environment variables and the same [Network] section of config.ini instead, read-only, importing nothing. Measured against the built artifact: bundle 3002 KB -> 5.3 KB cpu 154 ms -> ~30 ms per probe (bare node is ~27 ms) data dir created -> untouched Behavior is unchanged across 200, 500, unix socket, refused connection and https=true; the silent server now exits 1 after 2032 ms. Duplicating the resolution is the cost, so the tests load config.ts, port.ts and host.ts over six environments and assert both readings agree, rather than checking hand-written expectations. build.ts fails the build past 100 KB, verified by lowering the limit until it fired; that guard runs on every image build, unlike spec/build-checks, which no workflow invokes. healthcheck.ts is at 100% lines, branches and functions. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| build-server.sh | ||
| build.ts | ||
| export-schema.sh | ||
| generate_document.ts | ||
| generate-cert.sh | ||