Browse Source

feat(nocodb): throw timeout error for connecting to external data dbs

pull/5154/head
Wing-Kam Wong 2 years ago
parent
commit
6012549ad9
  1. 10
      packages/nocodb/src/lib/version-upgrader/ncAttachmentUpgrader.ts
  2. 10
      packages/nocodb/src/lib/version-upgrader/ncAttachmentUpgrader_0104002.ts

10
packages/nocodb/src/lib/version-upgrader/ncAttachmentUpgrader.ts

@ -6,6 +6,7 @@ import Model from '../models/Model';
import { XKnex } from '../db/sql-data-mapper/index'; import { XKnex } from '../db/sql-data-mapper/index';
import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2';
import { BaseType, UITypes } from 'nocodb-sdk'; import { BaseType, UITypes } from 'nocodb-sdk';
import { throwTimeoutError } from './ncUpgradeErrors';
// before 0.103.0, an attachment object was like // before 0.103.0, an attachment object was like
// [{ // [{
@ -68,6 +69,12 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
: NcConnectionMgrv2.get(base); : NcConnectionMgrv2.get(base);
const models = await base.getModels(ncMeta); const models = await base.getModels(ncMeta);
// used in timeout error message
const timeoutErrorInfo = {
projectTitle: project.title,
connection: knex.client.config.connection,
};
for (const model of models) { for (const model of models) {
try { try {
// if the table is missing in database, skip // if the table is missing in database, skip
@ -168,6 +175,9 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
} }
await Promise.all(updateRecords); await Promise.all(updateRecords);
} catch (e) { } catch (e) {
// throw the custom timeout error message if applicable
throwTimeoutError(e, timeoutErrorInfo);
// ignore the error related to deleted project // ignore the error related to deleted project
if (!isProjectDeleted) { if (!isProjectDeleted) {
throw e; throw e;

10
packages/nocodb/src/lib/version-upgrader/ncAttachmentUpgrader_0104002.ts

@ -6,6 +6,7 @@ import Model from '../models/Model';
import { XKnex } from '../db/sql-data-mapper/index'; import { XKnex } from '../db/sql-data-mapper/index';
import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2';
import { BaseType, UITypes } from 'nocodb-sdk'; import { BaseType, UITypes } from 'nocodb-sdk';
import { throwTimeoutError } from './ncUpgradeErrors';
// after 0101002 upgrader, the attachment object would become broken when // after 0101002 upgrader, the attachment object would become broken when
// (1) switching views after updating a singleSelect field // (1) switching views after updating a singleSelect field
@ -60,6 +61,12 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
: NcConnectionMgrv2.get(base); : NcConnectionMgrv2.get(base);
const models = await base.getModels(ncMeta); const models = await base.getModels(ncMeta);
// used in timeout error message
const timeoutErrorInfo = {
projectTitle: project.title,
connection: knex.client.config.connection,
};
for (const model of models) { for (const model of models) {
try { try {
// if the table is missing in database, skip // if the table is missing in database, skip
@ -149,6 +156,9 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
} }
await Promise.all(updateRecords); await Promise.all(updateRecords);
} catch (e) { } catch (e) {
// throw the custom timeout error message if applicable
throwTimeoutError(e, timeoutErrorInfo);
// ignore the error related to deleted project // ignore the error related to deleted project
if (!isProjectDeleted) { if (!isProjectDeleted) {
throw e; throw e;

Loading…
Cancel
Save