Browse Source

fix: handle async error for streamModelDataAsCsv

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6427/head
mertmit 1 year ago
parent
commit
6a433945a3
  1. 28
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts
  2. 9
      packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts

28
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts

@ -242,7 +242,11 @@ export class DuplicateProcessor {
let handledLinks = [];
let error = null;
for (const sourceModel of sourceModels) {
if (error) break;
const dataStream = new Readable({
read() {},
});
@ -251,12 +255,19 @@ export class DuplicateProcessor {
read() {},
});
this.exportService.streamModelDataAsCsv({
this.exportService
.streamModelDataAsCsv({
dataStream,
linkStream,
projectId: sourceProject.id,
modelId: sourceModel.id,
handledMmList: handledLinks,
})
.catch((e) => {
this.logger.error(e);
dataStream.push(null);
linkStream.push(null);
error = e;
});
const model = await Model.get(findWithIdentifier(idMap, sourceModel.id));
@ -284,6 +295,8 @@ export class DuplicateProcessor {
);
}
if (error) throw error;
// update external models (has bt to this model)
if (externalModels) {
for (const sourceModel of externalModels) {
@ -299,13 +312,22 @@ export class DuplicateProcessor {
read() {},
});
this.exportService.streamModelDataAsCsv({
let error = null;
this.exportService
.streamModelDataAsCsv({
dataStream,
linkStream,
projectId: sourceProject.id,
modelId: sourceModel.id,
handledMmList: handledLinks,
_fieldIds: fields,
})
.catch((e) => {
this.logger.error(e);
dataStream.push(null);
linkStream.push(null);
error = e;
});
const headers: string[] = [];
@ -401,6 +423,8 @@ export class DuplicateProcessor {
});
});
if (error) throw error;
elapsedTime(
hrTime,
`map existing links to ${model.title}`,

9
packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts

@ -722,15 +722,24 @@ export class ExportService {
dataStream,
);
let error = null;
this.streamModelDataAsCsv({
dataStream,
linkStream,
projectId: project.id,
modelId: model.id,
handledMmList,
}).catch((e) => {
this.logger.error(e);
dataStream.push(null);
linkStream.push(null);
error = e;
});
await Promise.all([uploadPromise, linkPromise]);
if (error) throw error;
}
combinedLinkStream.push(null);

Loading…
Cancel
Save