fix: restore OpenCode health compatibility for startup (#1542)
This commit is contained in:
@@ -547,7 +547,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const probeTargets: Array<{ label: string; path: string; includeDirectory?: boolean; timeoutMs?: number }> = [
|
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: 'config', path: '/config', includeDirectory: true },
|
||||||
{ label: 'providers', path: '/config/providers', includeDirectory: true },
|
{ label: 'providers', path: '/config/providers', includeDirectory: true },
|
||||||
// Can be slower on large configs; keep the probe from producing false negatives.
|
// Can be slower on large configs; keep the probe from producing false negatives.
|
||||||
|
|||||||
@@ -567,8 +567,8 @@ async function waitForReady(
|
|||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), 3000);
|
const timeout = setTimeout(() => controller.abort(), 3000);
|
||||||
|
|
||||||
// OpenCode readiness check.
|
// OpenCode readiness check. Use /global/health for OpenCode 1.15.x compatibility.
|
||||||
const url = new URL(`${baseUrl}/api/health`);
|
const url = new URL(`${baseUrl}/global/health`);
|
||||||
const res = await fetch(url.toString(), {
|
const res = await fetch(url.toString(), {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { Accept: 'application/json', ...authHeaders },
|
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_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 HEALTH_CHECK_RESULT_CACHE_MS = parsePositiveInt(process.env.OPENCHAMBER_OPENCODE_HEALTH_CACHE_MS, 750);
|
||||||
|
const OPENCODE_HEALTH_PATH = '/global/health';
|
||||||
|
|
||||||
export const createOpenCodeLifecycleRuntime = (deps) => {
|
export const createOpenCodeLifecycleRuntime = (deps) => {
|
||||||
const {
|
const {
|
||||||
@@ -392,7 +393,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(buildOpenCodeUrl('/api/health', ''), {
|
const response = await fetch(buildOpenCodeUrl(OPENCODE_HEALTH_PATH, ''), {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -417,7 +418,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), 3000);
|
const timeout = setTimeout(() => controller.abort(), 3000);
|
||||||
const base = origin ?? `http://127.0.0.1:${port}`;
|
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',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -663,7 +664,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
timeout = setTimeout(() => controller.abort(), HEALTH_CHECK_TIMEOUT_MS);
|
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',
|
method: 'GET',
|
||||||
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const createOpenCodeNetworkRuntime = (deps) => {
|
|||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
timeout = setTimeout(() => controller.abort(), 3000);
|
timeout = setTimeout(() => controller.abort(), 3000);
|
||||||
const response = await fetch(`${url.replace(/\/+$/, '')}/api/health`, {
|
const response = await fetch(`${url.replace(/\/+$/, '')}/global/health`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|||||||
|
|
||||||
app.get('/api/opencode/health', async (_req, res) => {
|
app.get('/api/opencode/health', async (_req, res) => {
|
||||||
try {
|
try {
|
||||||
const healthResponse = await fetch(buildOpenCodeUrl('/api/health', ''), {
|
const healthResponse = await fetch(buildOpenCodeUrl('/global/health', ''), {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user