Public: anyone can read this; the crew can change it.
Move the accessors out of looks/service.ts (keepLook, lookUrl, memoryPressure) so it leaves the boot's static closure #17277
Merged 41h 17m ago, live in production
mason/forge:mason/17182-move-the-accessors-out-of-looks-service → main 0 commits fork 1 thread · 1 unresolved
17 files
changed +102
−92
- src/actions/front.ts
- src/actions/journey_walk.ts
- src/looks/explore_pictures.ts
- src/looks/grant_url.ts
- src/looks/keep.ts
- src/looks/memory_pressure.ts
- src/looks/readable.ts
- src/looks/service.ts
- src/looks/why.ts
- src/runs/memory_hold.ts
- src/web/og/looks.ts
- test/boot-lazy.test.ts
- test/front.test.ts
- test/look-none.test.ts
- test/look-probe.test.ts
- test/look-secure-grant.test.ts
- test/looks.test.ts
src/actions/front.ts +1 −1
| @@ -47,7 +47,7 @@ import { | ||
| 47 | 47 | lookUrl, |
| 48 | 48 | type Look, |
| 49 | 49 | } from "../core/looks.ts"; |
| 50 | import { keepLook } from "../looks/service.ts"; | |
| 50 | import { keepLook } from "../looks/keep.ts"; | |
| 51 | 51 | import { retryAt } from "../looks/retries.ts"; |
| 52 | 52 | import { whyNoPicture } from "../looks/why.ts"; |
| 53 | 53 | import { canReadMany, getRepo, getReposByIds, type Repo } from "../core/repos.ts"; |
src/actions/journey_walk.ts +2 −2
| @@ -24,7 +24,7 @@ import { oneShot } from "../crew/one_shot.ts"; | ||
| 24 | 24 | import { ownHost, localFor } from "../kernel/own_host.ts"; |
| 25 | 25 | import { err, ok, type Result } from "../kernel/result.ts"; |
| 26 | 26 | import { closeBrowsers, takeLook } from "../looks/capture.ts"; |
| 27 | import { lookUrl } from "../looks/service.ts"; | |
| 27 | import { grantLookUrl } from "../looks/grant_url.ts"; | |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * What a visit to the app brings back: the page's text and where its picture is (or "" if none). |
| @@ -90,7 +90,7 @@ export async function visitApp(app: App, repo: Repo, out: string): Promise<Resul | ||
| 90 | 90 | const { dataDir } = app.config; |
| 91 | 91 | const host = runtime.hostFor(record.slug, "production"); |
| 92 | 92 | const token = signGrant(dataDir, { app: record, env: "production" }, GRANT_TTL_MS, Date.now(), { id: owner.id, name: owner.username, role: "admin" }); |
| 93 | const url = lookUrl(dataDir, host, local.port, token, "/"); | |
| 93 | const url = grantLookUrl(dataDir, host, local.port, token, "/"); | |
| 94 | 94 | // The text: through the grant door by hand, then the page with the cookie it set. |
| 95 | 95 | let text = ""; |
| 96 | 96 | try { |
src/looks/explore_pictures.ts +1 −1
| @@ -8,7 +8,7 @@ import type { Database } from "bun:sqlite"; | ||
| 8 | 8 | import { existsSync } from "node:fs"; |
| 9 | 9 | import { join } from "node:path"; |
| 10 | 10 | import { DEFAULT_THEME, lookUrl, type Look, type LookKind } from "../core/looks.ts"; |
| 11 | import { keepLook } from "./service.ts"; | |
| 11 | import { keepLook } from "./keep.ts"; | |
| 12 | 12 | |
| 13 | 13 | interface Found { |
| 14 | 14 | readonly repo_id: string; |
src/looks/grant_url.ts added +19
| @@ -0,0 +1,19 @@ | ||
| 1 | /** The URL the look's browser opens: the app's grant door on the forge's plain-http listener. */ | |
| 2 | ||
| 3 | import { plainProof } from "../apps/grants.ts"; | |
| 4 | ||
| 5 | /** | |
| 6 | * What the browser opens: the app's grant door on the forge's own plain-http | |
| 7 | * listener. The `plain` proof tells the door this is that browser, which | |
| 8 | * would drop a `Secure` cookie on http, so a forge whose public address is | |
| 9 | * https still hands it a cookie it keeps (#11519). | |
| 10 | */ | |
| 11 | export function grantLookUrl( | |
| 12 | dataDir: string, | |
| 13 | host: string, | |
| 14 | port: string, | |
| 15 | token: string, | |
| 16 | page: string, | |
| 17 | ): string { | |
| 18 | return `http://${host}:${port}/__forge/grant?t=${encodeURIComponent(token)}&plain=${plainProof(dataDir, token)}&to=${encodeURIComponent(page)}`; | |
| 19 | } |
src/looks/keep.ts added +31
| @@ -0,0 +1,31 @@ | ||
| 1 | /** Whether a picture on record is one to keep (its row and its file on disk). */ | |
| 2 | ||
| 3 | import { closeSync, openSync, readSync } from "node:fs"; | |
| 4 | import { join } from "node:path"; | |
| 5 | import { LEGACY_THUMB_WIDTH, type Look } from "../core/looks.ts"; | |
| 6 | import { pngHeader } from "../design/image/png.ts"; | |
| 7 | ||
| 8 | /** | |
| 9 | * Whether a picture on record is one to keep. Every one is, except a | |
| 10 | * thumb from before thumbs were the page reduced (`LEGACY_THUMB_WIDTH`): | |
| 11 | * that one is retaken, and shown until it is. | |
| 12 | */ | |
| 13 | export function keepLook(dataDir: string, look: Look, staleBefore?: number): boolean { | |
| 14 | if (look.error !== null) return false; | |
| 15 | if (look.kind !== "thumb") return true; | |
| 16 | // A thumb older than the cut is one to retake; it is still shown until the retake lands. | |
| 17 | if (staleBefore !== undefined && Date.parse(look.createdAt) < staleBefore) return false; | |
| 18 | let fd: number | undefined; | |
| 19 | try { | |
| 20 | fd = openSync(join(dataDir, look.path), "r"); | |
| 21 | const head = new Uint8Array(33); | |
| 22 | readSync(fd, head, 0, 33, 0); | |
| 23 | const parsed = pngHeader(head); | |
| 24 | return !parsed.ok || parsed.value.width !== LEGACY_THUMB_WIDTH; | |
| 25 | } catch { | |
| 26 | // No file behind the row: nothing to show, so nothing to keep. | |
| 27 | return false; | |
| 28 | } finally { | |
| 29 | if (fd !== undefined) closeSync(fd); | |
| 30 | } | |
| 31 | } |
src/looks/memory_pressure.ts added +21
| @@ -0,0 +1,21 @@ | ||
| 1 | /** The share of a container's memory limit in use, from cgroup v2 file contents. */ | |
| 2 | ||
| 3 | /** | |
| 4 | * The share of the limit the container truly holds. `memory.current` | |
| 5 | * counts the page cache too — every git object and database page read | |
| 6 | * lately, which the kernel hands back the moment anyone needs it — and a | |
| 7 | * forge that reads its repositories all day sits above any ceiling by that | |
| 8 | * number for good. The anonymous pages are what would have to give. | |
| 9 | */ | |
| 10 | export function memoryPressure( | |
| 11 | stat: string, | |
| 12 | max: string, | |
| 13 | current: string, | |
| 14 | ): number | undefined { | |
| 15 | if (max.trim() === "max") return undefined; | |
| 16 | const limit = Number(max); | |
| 17 | if (!(limit > 0)) return undefined; | |
| 18 | const anon = /^anon (\d+)$/m.exec(stat); | |
| 19 | const used = anon === null ? Number(current) : Number(anon[1]); | |
| 20 | return Number.isFinite(used) ? used / limit : undefined; | |
| 21 | } |
src/looks/readable.ts +1 −1
| @@ -13,7 +13,7 @@ import { canEnterApp, canSeeOwnerFacts, type Repo } from "../core/repos.ts"; | ||
| 13 | 13 | import { sealedPreview } from "../core/sealed.ts"; |
| 14 | 14 | import type { User } from "../core/users.ts"; |
| 15 | 15 | import { pairCounts, pairsLine } from "./pairs.ts"; |
| 16 | import { keepLook } from "./service.ts"; | |
| 16 | import { keepLook } from "./keep.ts"; | |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Who may fetch a picture (#727, #738). Writers, all of them. Anyone else |
src/looks/service.ts +6 −74
| @@ -25,20 +25,17 @@ | ||
| 25 | 25 | |
| 26 | 26 | import { sealedPreview } from "../core/sealed.ts"; |
| 27 | 27 | import { |
| 28 | closeSync, | |
| 29 | 28 | existsSync, |
| 30 | 29 | mkdirSync, |
| 31 | openSync, | |
| 32 | 30 | readdirSync, |
| 33 | 31 | readFileSync, |
| 34 | readSync, | |
| 35 | 32 | renameSync, |
| 36 | 33 | rmSync, |
| 37 | 34 | } from "node:fs"; |
| 38 | 35 | import { dirname, join } from "node:path"; |
| 39 | 36 | import type { App } from "../app.ts"; |
| 40 | 37 | import { envBuild, envPull, isEnvName, previewEnv, type EnvName } from "../apps/data.ts"; |
| 41 | import { plainProof, signGrant, type GrantWho } from "../apps/grants.ts"; | |
| 38 | import { signGrant, type GrantWho } from "../apps/grants.ts"; | |
| 42 | 39 | import { appsRuntime } from "../apps/runtime_registry.ts"; |
| 43 | 40 | import { |
| 44 | 41 | getAppById, |
| @@ -51,7 +48,6 @@ import { | ||
| 51 | 48 | deleteLooks, |
| 52 | 49 | deleteStrangerThumbs, |
| 53 | 50 | DEFAULT_PAGE, |
| 54 | LEGACY_THUMB_WIDTH, | |
| 55 | 51 | DARK_KINDS, |
| 56 | 52 | DEFAULT_THEME, |
| 57 | 53 | kindsOfPage, |
| @@ -64,7 +60,6 @@ import { | ||
| 64 | 60 | getLook, |
| 65 | 61 | looksForEnv, |
| 66 | 62 | recordLook, |
| 67 | type Look, | |
| 68 | 63 | type LookKind, |
| 69 | 64 | } from "../core/looks.ts"; |
| 70 | 65 | import { crewHoldsCore, forgeCpus } from "../core/one_core.ts"; |
| @@ -74,10 +69,13 @@ import { frontPicks } from "../core/front.ts"; | ||
| 74 | 69 | import { getRepoById } from "../core/repos.ts"; |
| 75 | 70 | import { getUserById } from "../core/users.ts"; |
| 76 | 71 | import { ownerLooksFor, PREVIEW_EVERYDAY, PREVIEW_NEWCOMER } from "../spawn/preview-looks.ts"; |
| 77 | import { pngHeader } from "../design/image/png.ts"; | |
| 78 | 72 | import { createLog } from "../kernel/log.ts"; |
| 79 | 73 | import { addCommitLook } from "../checks/looks.ts"; |
| 80 | 74 | import type { LookVitals } from "../checks/summary.ts"; |
| 75 | import { NOT_SERVING } from "./why.ts"; | |
| 76 | import { grantLookUrl } from "./grant_url.ts"; | |
| 77 | import { keepLook } from "./keep.ts"; | |
| 78 | import { memoryPressure } from "./memory_pressure.ts"; | |
| 81 | 79 | import { blobKey, deleteLooksAndObjects, deleteObjects } from "./archive.ts"; |
| 82 | 80 | import { keepAsMain } from "./main_looks.ts"; |
| 83 | 81 | import { closeBrowsers, findChromium, isNoBrowser, lookLanes, takeLook, type Capture } from "./capture.ts"; |
| @@ -121,11 +119,6 @@ export interface LooksOptions { | ||
| 121 | 119 | readonly maxWaitMs?: number | undefined; |
| 122 | 120 | } |
| 123 | 121 | |
| 124 | /** | |
| 125 | * What a look records when the app answers, but with a missing page or a | |
| 126 | * server error: not serving. | |
| 127 | */ | |
| 128 | export const NOT_SERVING = "not serving"; | |
| 129 | 122 | |
| 130 | 123 | /** |
| 131 | 124 | * The app serves when its page comes back with anything but a 404 or a |
| @@ -164,26 +157,6 @@ export function cgroupMemoryPressure(): number | undefined { | ||
| 164 | 157 | } |
| 165 | 158 | } |
| 166 | 159 | |
| 167 | /** | |
| 168 | * The share of the limit the container truly holds. `memory.current` | |
| 169 | * counts the page cache too — every git object and database page read | |
| 170 | * lately, which the kernel hands back the moment anyone needs it — and a | |
| 171 | * forge that reads its repositories all day sits above any ceiling by that | |
| 172 | * number for good. The anonymous pages are what would have to give. | |
| 173 | */ | |
| 174 | export function memoryPressure( | |
| 175 | stat: string, | |
| 176 | max: string, | |
| 177 | current: string, | |
| 178 | ): number | undefined { | |
| 179 | if (max.trim() === "max") return undefined; | |
| 180 | const limit = Number(max); | |
| 181 | if (!(limit > 0)) return undefined; | |
| 182 | const anon = /^anon (\d+)$/m.exec(stat); | |
| 183 | const used = anon === null ? Number(current) : Number(anon[1]); | |
| 184 | return Number.isFinite(used) ? used / limit : undefined; | |
| 185 | } | |
| 186 | ||
| 187 | 160 | /** Above this share of the limit, a look waits. */ |
| 188 | 161 | const PRESSURE_CEILING = 0.7; |
| 189 | 162 | |
| @@ -252,31 +225,6 @@ export const lookPath = ( | ||
| 252 | 225 | ): string => |
| 253 | 226 | join("looks", appId, env, `${commitOid}-${lookSlot(page, kind, theme)}.png`); |
| 254 | 227 | |
| 255 | /** | |
| 256 | * Whether a picture on record is one to keep. Every one is, except a | |
| 257 | * thumb from before thumbs were the page reduced (`LEGACY_THUMB_WIDTH`): | |
| 258 | * that one is retaken, and shown until it is. | |
| 259 | */ | |
| 260 | export function keepLook(dataDir: string, look: Look, staleBefore?: number): boolean { | |
| 261 | if (look.error !== null) return false; | |
| 262 | if (look.kind !== "thumb") return true; | |
| 263 | // A thumb older than the cut is one to retake; it is still shown until the retake lands. | |
| 264 | if (staleBefore !== undefined && Date.parse(look.createdAt) < staleBefore) return false; | |
| 265 | let fd: number | undefined; | |
| 266 | try { | |
| 267 | fd = openSync(join(dataDir, look.path), "r"); | |
| 268 | const head = new Uint8Array(33); | |
| 269 | readSync(fd, head, 0, 33, 0); | |
| 270 | const parsed = pngHeader(head); | |
| 271 | return !parsed.ok || parsed.value.width !== LEGACY_THUMB_WIDTH; | |
| 272 | } catch { | |
| 273 | // No file behind the row: nothing to show, so nothing to keep. | |
| 274 | return false; | |
| 275 | } finally { | |
| 276 | if (fd !== undefined) closeSync(fd); | |
| 277 | } | |
| 278 | } | |
| 279 | ||
| 280 | 228 | interface Pending { |
| 281 | 229 | readonly appId: string; |
| 282 | 230 | readonly env: EnvName; |
| @@ -288,22 +236,6 @@ interface Pending { | ||
| 288 | 236 | readonly again?: true; |
| 289 | 237 | } |
| 290 | 238 | |
| 291 | /** | |
| 292 | * What the browser opens: the app's grant door on the forge's own plain-http | |
| 293 | * listener. The `plain` proof tells the door this is that browser, which | |
| 294 | * would drop a `Secure` cookie on http, so a forge whose public address is | |
| 295 | * https still hands it a cookie it keeps (#11519). | |
| 296 | */ | |
| 297 | export function lookUrl( | |
| 298 | dataDir: string, | |
| 299 | host: string, | |
| 300 | port: string, | |
| 301 | token: string, | |
| 302 | page: string, | |
| 303 | ): string { | |
| 304 | return `http://${host}:${port}/__forge/grant?t=${encodeURIComponent(token)}&plain=${plainProof(dataDir, token)}&to=${encodeURIComponent(page)}`; | |
| 305 | } | |
| 306 | ||
| 307 | 239 | export function startLooks(app: App, options: LooksOptions): LooksHandle { |
| 308 | 240 | const { dataDir } = app.config; |
| 309 | 241 | const port = new URL(options.localUrl).port; |
| @@ -682,7 +614,7 @@ export function startLooks(app: App, options: LooksOptions): LooksHandle { | ||
| 682 | 614 | Date.now(), |
| 683 | 615 | asNobody(kind, page) ? undefined : isNewcomerLook(page) ? newcomer : isEverydayLook(page) ? everyday : asOwner, |
| 684 | 616 | ); |
| 685 | const url = lookUrl(dataDir, host, port, token, page); | |
| 617 | const url = grantLookUrl(dataDir, host, port, token, page); | |
| 686 | 618 | const path = lookPath(item.appId, item.env, item.commitOid, page, kind, theme); |
| 687 | 619 | const out = join(dataDir, path); |
| 688 | 620 | // Taken to one side and moved in whole. A pull that closes while its |
src/looks/why.ts +6 −1
| @@ -6,7 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import type { EnvState } from "../apps/runtime.ts"; |
| 9 | import { NOT_SERVING } from "./service.ts"; | |
| 9 | ||
| 10 | /** | |
| 11 | * What a look records when the app answers, but with a missing page or a | |
| 12 | * server error: not serving. | |
| 13 | */ | |
| 14 | export const NOT_SERVING = "not serving"; | |
| 10 | 15 | |
| 11 | 16 | export interface NoPicture { |
| 12 | 17 | /** Whether this viewer may be shown the app's pictures (`mayFetchLook`; a public app's: yes). */ |
src/runs/memory_hold.ts +1 −1
| @@ -14,7 +14,7 @@ | ||
| 14 | 14 | |
| 15 | 15 | import { readFileSync } from "node:fs"; |
| 16 | 16 | import { join } from "node:path"; |
| 17 | import { memoryPressure } from "../looks/service.ts"; | |
| 17 | import { memoryPressure } from "../looks/memory_pressure.ts"; | |
| 18 | 18 | import { isSize } from "../spawn/sizes.ts"; |
| 19 | 19 | import { CGROUP_DIR_ENV, SIZE_ENV } from "../spawn/usage.ts"; |
| 20 | 20 |
src/web/og/looks.ts +1 −1
| @@ -11,7 +11,7 @@ import { previewEnv } from "../../apps/data.ts"; | ||
| 11 | 11 | import type { AppRecord } from "../../core/apps.ts"; |
| 12 | 12 | import { DEFAULT_PAGE, looksForEnv, lookVersion, type Look } from "../../core/looks.ts"; |
| 13 | 13 | import { sealedPreview } from "../../core/sealed.ts"; |
| 14 | import { keepLook } from "../../looks/service.ts"; | |
| 14 | import { keepLook } from "../../looks/keep.ts"; | |
| 15 | 15 | import type { App } from "../../app.ts"; |
| 16 | 16 | import type { CardImage, CardInput } from "./card.ts"; |
| 17 | 17 | import { shotUri } from "./shot.ts"; |
test/boot-lazy.test.ts +3 −2
| @@ -24,11 +24,12 @@ test("the terminal's server is imported dynamically by the boot", () => { | ||
| 24 | 24 | // #17021: the services only the boot starts are not in its static closure; that each still starts |
| 25 | 25 | // is proved on a real boot (boot-production.test.ts, "background service started service=<name>"). |
| 26 | 26 | // The heavier ones are still reached by pages and actions, each its own follow-up: #17180, |
| 27 | // #17181, #17182, #17183 (checks/service, crew/dispatch, looks/service). | |
| 27 | // #17181, #17183 (checks/service, crew/dispatch). | |
| 28 | // looks/service is out (#17182): its accessors live in looks/keep.ts, grant_url.ts and memory_pressure.ts. | |
| 28 | 29 | // apps/runtime is out (#17179): its accessors live in apps/runtime_registry.ts. |
| 29 | 30 | test("the boot's static imports do not reach the services only it starts", () => { |
| 30 | 31 | const closure = [...staticClosure(resolve("src/main.ts"))]; |
| 31 | const only = ["maintain/runner.ts", "nightly/service.ts", "keeper/keeper.ts", "keeper/wire.ts", "crew/routines.ts", "checks/service.ts", "snapshot/service.ts", "apps/runtime.ts"]; | |
| 32 | const only = ["maintain/runner.ts", "nightly/service.ts", "keeper/keeper.ts", "keeper/wire.ts", "crew/routines.ts", "checks/service.ts", "snapshot/service.ts", "apps/runtime.ts", "looks/service.ts"]; | |
| 32 | 33 | for (const file of only) expect(closure.some((f) => f.endsWith(`/src/${file}`)), file).toBe(false); |
| 33 | 34 | }); |
| 34 | 35 |
test/front.test.ts +1 −1
| @@ -15,7 +15,7 @@ import { lookNow } from "../src/web/pages/looks.ts"; | ||
| 15 | 15 | import type { Ctx } from "../src/http/context.ts"; |
| 16 | 16 | import { suspendAccount } from "../src/actions/accounts.ts"; |
| 17 | 17 | import { forgetFrontScores, frontPage } from "../src/actions/front.ts"; |
| 18 | import * as lookService from "../src/looks/service.ts"; | |
| 18 | import * as lookService from "../src/looks/keep.ts"; | |
| 19 | 19 | import { openIssue } from "../src/actions/issues.ts"; |
| 20 | 20 | import { createRepo } from "../src/actions/repos.ts"; |
| 21 | 21 | import { changeSignup } from "../src/actions/signup.ts"; |
test/look-none.test.ts +1 −2
| @@ -4,8 +4,7 @@ import { tmpdir } from "node:os"; | ||
| 4 | 4 | import { join } from "node:path"; |
| 5 | 5 | import { createApp, type App } from "../src/app.ts"; |
| 6 | 6 | import { clearRetry, noteRetry, retryAt } from "../src/looks/retries.ts"; |
| 7 | import { NOT_SERVING } from "../src/looks/service.ts"; | |
| 8 | import { whyNoPicture } from "../src/looks/why.ts"; | |
| 7 | import { NOT_SERVING, whyNoPicture } from "../src/looks/why.ts"; | |
| 9 | 8 | import { noPicture } from "../src/web/look_none.ts"; |
| 10 | 9 | |
| 11 | 10 | const dir = mkdtempSync(join(tmpdir(), "look-none-")); |
test/look-probe.test.ts +2 −1
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { afterAll, expect, test } from "bun:test"; |
| 2 | import { appAnswers, NOT_SERVING } from "../src/looks/service.ts"; | |
| 2 | import { appAnswers } from "../src/looks/service.ts"; | |
| 3 | import { NOT_SERVING } from "../src/looks/why.ts"; | |
| 3 | 4 | import { lookFlags } from "../src/looks/capture.ts"; |
| 4 | 5 | |
| 5 | 6 | const server = Bun.serve({ |
test/look-secure-grant.test.ts +1 −1
| @@ -16,7 +16,7 @@ import { signGrant } from "../src/apps/proxy.ts"; | ||
| 16 | 16 | import { newApp } from "../src/actions/apps.ts"; |
| 17 | 17 | import { createUser } from "../src/core/users.ts"; |
| 18 | 18 | import { serve } from "../src/http/server.ts"; |
| 19 | import { lookUrl } from "../src/looks/service.ts"; | |
| 19 | import { grantLookUrl as lookUrl } from "../src/looks/grant_url.ts"; | |
| 20 | 20 | import { refusal } from "../src/looks/capture.ts"; |
| 21 | 21 | import { quietLogs } from "./helpers/globals.ts"; |
| 22 | 22 |
test/looks.test.ts +4 −3
| @@ -44,7 +44,8 @@ import { | ||
| 44 | 44 | type Capture, |
| 45 | 45 | type LookInput, |
| 46 | 46 | } from "../src/looks/capture.ts"; |
| 47 | import { NOT_ANSWERING, NOT_SERVING, startLooks, type LooksHandle } from "../src/looks/service.ts"; | |
| 47 | import { NOT_ANSWERING, startLooks, type LooksHandle } from "../src/looks/service.ts"; | |
| 48 | import { NOT_SERVING } from "../src/looks/why.ts"; | |
| 48 | 49 | import type { BackoffClock } from "../src/looks/backoff.ts"; |
| 49 | 50 | import { logLevel, setLogLevel } from "../src/kernel/log.ts"; |
| 50 | 51 | |
| @@ -1584,8 +1585,8 @@ describe("the look", () => { | ||
| 1584 | 1585 | }); |
| 1585 | 1586 | |
| 1586 | 1587 | test("memory pressure is what the container truly holds, never its page cache", async () => { |
| 1587 | const { cgroupMemoryPressure, memoryPressure } = | |
| 1588 | await import("../src/looks/service.ts"); | |
| 1588 | const { cgroupMemoryPressure } = await import("../src/looks/service.ts"); | |
| 1589 | const { memoryPressure } = await import("../src/looks/memory_pressure.ts"); | |
| 1589 | 1590 | // Not a container here: unknown pressure is no pressure. |
| 1590 | 1591 | expect( |
| 1591 | 1592 | cgroupMemoryPressure() === undefined || cgroupMemoryPressure()! >= 0, |
new above
offline
The alias
lookServicenow nameskeep.ts. Rename it (for examplekeep) so the spy at thespyOn(lookService, "keepLook")call reads true.