Repository navigation
fix(client): preserve slow-starting managed services #59246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { homedir } from "node:os" | ||
| import { join } from "node:path" | ||
| import type { DiscoverOptions, Endpoint, Info } from "./service.js" | ||
| import { defaultEnsureTiming } from "./service-timing.js" | ||
| import { defaultEnsureTiming, type EnsureTiming } from "./service-timing.js" | ||
| import { matchesVersion } from "./service-version.js" | ||
|
|
||
| // Shared by the Effect and Promise clients. Keep this module free of Effect so the | ||
|
|
@@ -45,6 +45,16 @@ export function same(left: Info, right: Info) { | |
| return left.id === right.id && left.version === right.version && left.url === right.url && left.pid === right.pid | ||
| } | ||
|
|
||
| /** Keep a registered service's shared startup window open for every concurrent client. */ | ||
| export function withinStartupWindow(info: Info, timing: EnsureTiming) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This window only looks at the clock, so it also covers registrations whose process is already dead. When the probe gets connection refused (not a timeout), |
||
| return ( | ||
| info.startedAt !== undefined && | ||
| Number.isSafeInteger(info.startedAt) && | ||
| info.startedAt > 0 && | ||
| Date.now() < info.startedAt + timing.promiseTimeout | ||
| ) | ||
| } | ||
|
|
||
| /** Ask a registered owner for its health and classify the answer. */ | ||
| export async function probeResult(info: Info, timeout = defaultEnsureTiming.requestTimeout) { | ||
| const endpoint = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startingnow also stops recruitment for any registration inside its window, including one owned by another client. Before, an unanswered registration got onespawnDelaybefore a lock-probe contender competed with it. So the PR now changes more than eviction: a registration that never answers (dead, or bound to a port it no longer serves) blocks every client for up topromiseTimeout. The same logic is ineffect/service.ts.