Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions open-sse/services/browserPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ const state: PoolState = {
cloakLaunchResolved: false,
};

function getCloakbrowserModuleId(): string {
return ["cloak", "browser"].join("");
}
Comment on lines +81 to +85

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the Repository Style Guide (Rule 9 under Hard Rules), you must always include tests when changing production code in open-sse/. Please ensure that appropriate tests are added or updated in the tests/ directory to cover these changes.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

Comment on lines +81 to +85
Comment on lines +81 to +85

async function resolveCloakLaunch(): Promise<((opts: unknown) => Promise<Browser>) | null> {
if (state.cloakLaunchResolved) return state.cloakLaunch;
state.cloakLaunchResolved = true;
try {
const mod = (await import("cloakbrowser")) as unknown as {
const mod = (await import(getCloakbrowserModuleId())) as unknown as {
launch?: (opts: unknown) => Promise<Browser>;
};
state.cloakLaunch = mod.launch ?? null;
Expand Down Expand Up @@ -110,7 +114,12 @@ function evictStaleContexts(): void {
const now = Date.now();
for (const [key, pooled] of state.contexts) {
if (now - pooled.lastUsed > CONTEXT_TTL_MS) {
console.log("[BrowserPool] Evicted stale context:", key, "(idle", ((now - pooled.lastUsed) / 1000).toFixed(0) + "s)");
console.log(
"[BrowserPool] Evicted stale context:",
key,
"(idle",
((now - pooled.lastUsed) / 1000).toFixed(0) + "s)"
);
state.contexts.delete(key);
pooled.context.close().catch(() => {});
}
Expand Down