This commit is contained in:
@@ -159,7 +159,7 @@ export class CatalogService {
|
||||
for (const id of Object.values(CATALOG_SECRET_IDS)) this.secretStore.forget(workspaceId, id);
|
||||
}
|
||||
|
||||
async test(database: WorkspaceDatabase): Promise<DatabaseTestResult> {
|
||||
async test(database: WorkspaceDatabase): Promise<WorkspaceDatabase | undefined> {
|
||||
return await this.operations.run(database.id, async () => {
|
||||
const testedAt = new Date().toISOString();
|
||||
const controller = new AbortController();
|
||||
@@ -168,6 +168,7 @@ export class CatalogService {
|
||||
? database.binding.restAuth === "none" ? [] : [CATALOG_SECRET_IDS.apiKey]
|
||||
: [];
|
||||
const materialized = this.secretStore.materialize(database.workspaceId, required);
|
||||
let result: DatabaseTestResult;
|
||||
try {
|
||||
if (database.binding.transport !== "rest_api") {
|
||||
const client = await this.postgres.connect(database, controller.signal);
|
||||
@@ -205,13 +206,13 @@ export class CatalogService {
|
||||
},
|
||||
});
|
||||
}
|
||||
return {
|
||||
result = {
|
||||
connectionStatus: "reachable",
|
||||
testedVersion: database.version,
|
||||
lastTestedAt: testedAt,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
result = {
|
||||
connectionStatus: "failed",
|
||||
testedVersion: database.version,
|
||||
lastTestedAt: testedAt,
|
||||
@@ -223,6 +224,7 @@ export class CatalogService {
|
||||
controller.abort();
|
||||
materialized.release();
|
||||
}
|
||||
return await this.repository.recordTest(database.id, database.version, result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user