Skip to content

Commit 9fe1dee

Browse files
committed
fix(backend): update instance status during reconnection process
1 parent 540e637 commit 9fe1dee

File tree

1 file changed

+20
-1
lines changed
  • services/backend/src/routes/teams/mcp-installations

1 file changed

+20
-1
lines changed

services/backend/src/routes/teams/mcp-installations/reconnect.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ export default async function reconnectInstallationRoute(server: FastifyInstance
219219
return reply.status(400).type('application/json').send(JSON.stringify(errorResponse));
220220
}
221221

222+
// Immediately update instance status so frontend reflects the change via SSE
223+
await db
224+
.update(mcpServerInstances)
225+
.set({
226+
status: 'connecting',
227+
status_message: 'Reconnection in progress',
228+
status_updated_at: new Date(),
229+
})
230+
.where(eq(mcpServerInstances.id, instance.id));
231+
222232
// Perform health check on the template
223233
const healthCheckService = new McpHealthCheckService(db, request.log);
224234
const healthResult = await healthCheckService.checkTemplateHealth(serverTemplate.id);
@@ -254,7 +264,16 @@ export default async function reconnectInstallationRoute(server: FastifyInstance
254264
};
255265
return reply.status(200).type('application/json').send(JSON.stringify(successResponse));
256266
} else {
257-
// Server is still offline
267+
// Server is still offline — revert instance status to original
268+
await db
269+
.update(mcpServerInstances)
270+
.set({
271+
status: instance.status,
272+
status_message: healthResult.error || 'Server is still unreachable',
273+
status_updated_at: new Date(),
274+
})
275+
.where(eq(mcpServerInstances.id, instance.id));
276+
258277
request.log.info({
259278
operation: 'reconnect_installation_still_offline',
260279
teamId,

0 commit comments

Comments
 (0)