Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: classify slow gbrain probes separately #1969

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

Open
RudraMalvankar wants to merge 1 commit into garrytan:main
base: main
Choose a base branch
Loading
from RudraMalvankar:fix/gbrain-slow-engine-timeout
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions bin/gstack-gbrain-sync.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ function skipStageForLocalStatus(
"config at ~/.gbrain/config.json is malformed; see /setup-gbrain Step 1.5",
"broken-db":
"config points at unreachable DB; see /setup-gbrain Step 1.5",
"slow-engine":
"gbrain probe exceeded timeout; engine may be reachable but slow. Increase GSTACK_GBRAIN_PROBE_TIMEOUT_MS or use a faster database connection",
};
const reason = reasons[status as Exclude<LocalEngineStatus, "ok">];
return {
Expand Down
14 changes: 12 additions & 2 deletions lib/gbrain-local-status.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export type LocalEngineStatus =
| "no-cli"
| "missing-config"
| "broken-config"
| "broken-db";
| "broken-db"
| "slow-engine";

export interface ClassifyOptions {
/** Bypass the 60s cache. Used after any state-mutating operation. */
Expand Down Expand Up @@ -73,7 +74,9 @@ interface CacheEntry {
}

export const CACHE_TTL_MS = 60_000;
export const PROBE_TIMEOUT_MS = 5_000;
export const PROBE_TIMEOUT_MS = Number(
process.env.GSTACK_GBRAIN_PROBE_TIMEOUT_MS ?? 20_000
);

/** Effective user home — respects HOME env override (used by tests). */
function userHome(): string {
Expand Down Expand Up @@ -252,6 +255,13 @@ function freshClassify(env?: NodeJS.ProcessEnv): LocalEngineStatus {

// ENOENT can happen if gbrain disappeared between resolveGbrainBin and now.
if (e.code === "ENOENT") return "no-cli";
// Distinguish slow-but-reachable engines from broken configs.
if (
e.code === "ETIMEDOUT" ||
stderr.toLowerCase().includes("timed out")
) {
return "slow-engine";
}

// Pattern match against gbrain's known error strings. Order matters:
// "Cannot connect to database" is the more specific DB-unreachable signal.
Expand Down
4 changes: 2 additions & 2 deletions test/gbrain-detect-shape.test.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe("bin/gstack-gbrain-detect — shape regression", () => {
}
});

it("gbrain_local_status is one of the five documented values", () => {
it("gbrain_local_status is one of the six documented values", () => {
const tmp = mkdtempSync(join(tmpdir(), "detect-shape-"));
try {
const out = runDetect({
Expand All @@ -186,7 +186,7 @@ describe("bin/gstack-gbrain-detect — shape regression", () => {
GSTACK_HOME: tmp,
});
const parsed = JSON.parse(out) as DetectShape;
expect(["ok", "no-cli", "missing-config", "broken-config", "broken-db"]).toContain(
expect(["ok", "no-cli", "missing-config", "broken-config", "broken-db","slow-engine",]).toContain(
parsed.gbrain_local_status,
);
} finally {
Expand Down

AltStyle によって変換されたページ (->オリジナル) /