fix: restore OpenCode health compatibility for startup (#1542)

This commit is contained in:
Bohdan Triapitsyn
2026-06-05 18:43:13 +03:00
parent 0f6602aabd
commit 3e0a105dfe
5 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -547,7 +547,7 @@ export async function activate(context: vscode.ExtensionContext) {
};
const probeTargets: Array<{ label: string; path: string; includeDirectory?: boolean; timeoutMs?: number }> = [
{ label: 'health', path: '/api/health', includeDirectory: false },
{ label: 'health', path: '/global/health', includeDirectory: false },
{ label: 'config', path: '/config', includeDirectory: true },
{ label: 'providers', path: '/config/providers', includeDirectory: true },
// Can be slower on large configs; keep the probe from producing false negatives.
+2 -2
View File
@@ -567,8 +567,8 @@ async function waitForReady(
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
// OpenCode readiness check.
const url = new URL(`${baseUrl}/api/health`);
// OpenCode readiness check. Use /global/health for OpenCode 1.15.x compatibility.
const url = new URL(`${baseUrl}/global/health`);
const res = await fetch(url.toString(), {
method: 'GET',
headers: { Accept: 'application/json', ...authHeaders },
@@ -13,6 +13,7 @@ const HEALTH_CHECK_MAX_CONSECUTIVE_FAILURES = parsePositiveInt(
);
const HEALTH_CHECK_INTERVAL_OVERRIDE_MS = parsePositiveInt(process.env.OPENCHAMBER_OPENCODE_HEALTH_INTERVAL_MS, 0);
const HEALTH_CHECK_RESULT_CACHE_MS = parsePositiveInt(process.env.OPENCHAMBER_OPENCODE_HEALTH_CACHE_MS, 750);
const OPENCODE_HEALTH_PATH = '/global/health';
export const createOpenCodeLifecycleRuntime = (deps) => {
const {
@@ -392,7 +393,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
}
try {
const response = await fetch(buildOpenCodeUrl('/api/health', ''), {
const response = await fetch(buildOpenCodeUrl(OPENCODE_HEALTH_PATH, ''), {
method: 'GET',
headers: {
Accept: 'application/json',
@@ -417,7 +418,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
const base = origin ?? `http://127.0.0.1:${port}`;
const response = await fetch(`${base}/api/health`, {
const response = await fetch(`${base}${OPENCODE_HEALTH_PATH}`, {
method: 'GET',
headers: {
Accept: 'application/json',
@@ -663,7 +664,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
try {
const controller = new AbortController();
timeout = setTimeout(() => controller.abort(), HEALTH_CHECK_TIMEOUT_MS);
const response = await fetch(buildOpenCodeUrl('/api/health', ''), {
const response = await fetch(buildOpenCodeUrl(OPENCODE_HEALTH_PATH, ''), {
method: 'GET',
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
signal: controller.signal,
@@ -33,7 +33,7 @@ export const createOpenCodeNetworkRuntime = (deps) => {
try {
const controller = new AbortController();
timeout = setTimeout(() => controller.abort(), 3000);
const response = await fetch(`${url.replace(/\/+$/, '')}/api/health`, {
const response = await fetch(`${url.replace(/\/+$/, '')}/global/health`, {
method: 'GET',
headers: {
Accept: 'application/json',
+1 -1
View File
@@ -214,7 +214,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
app.get('/api/opencode/health', async (_req, res) => {
try {
const healthResponse = await fetch(buildOpenCodeUrl('/api/health', ''), {
const healthResponse = await fetch(buildOpenCodeUrl('/global/health', ''), {
method: 'GET',
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
});