From 1a31eb991b95b1f7a2e9eb69f8e61fc9ab8b2044 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 27 Dec 2022 14:46:19 +0300 Subject: [PATCH 1/5] fix: proper error if provided url is not shared base Re #3927 Signed-off-by: mertmit --- packages/nocodb/src/lib/meta/api/sync/helpers/job.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts index 8f607b3bf6..9344c8f606 100644 --- a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts +++ b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts @@ -190,6 +190,13 @@ export default async ( const duration = Date.now() - start; rtc.fetchAt.count++; rtc.fetchAt.time += duration; + + if (!ft.baseId) { + throw { + message: + 'Invalid Shared Base ID :: Ensure www.airtable.com/ is accessible. Refer https://bit.ly/3x0OdXI for details', + }; + } const file = ft.schema; baseId = ft.baseId; From 2ecd914337e898cd4b629a584e22b016a8adcce0 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 27 Dec 2022 16:11:06 +0300 Subject: [PATCH 2/5] fix: proper error messages for wrong shared base and template ID Signed-off-by: mertmit --- .../src/lib/meta/api/sync/helpers/fetchAT.ts | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/sync/helpers/fetchAT.ts b/packages/nocodb/src/lib/meta/api/sync/helpers/fetchAT.ts index a99947dc09..eca0dacd3c 100644 --- a/packages/nocodb/src/lib/meta/api/sync/helpers/fetchAT.ts +++ b/packages/nocodb/src/lib/meta/api/sync/helpers/fetchAT.ts @@ -36,6 +36,12 @@ async function initialize(shareId) { info.cookie += ck.split(';')[0] + '; '; } return response.data; + }) + .catch(() => { + throw { + message: + 'Invalid Shared Base ID :: Ensure www.airtable.com/ is accessible. Refer https://bit.ly/3x0OdXI for details', + }; }); info.headers = JSON.parse( @@ -64,6 +70,14 @@ async function initialize(shareId) { } catch (e) { console.log(e); info.initialized = false; + if (e.message) { + throw e; + } else { + throw { + message: + 'Error processing Shared Base :: Ensure www.airtable.com/ is accessible. Refer https://bit.ly/3x0OdXI for details', + }; + } } } @@ -94,7 +108,10 @@ async function read() { return response.data; }) .catch(() => { - throw 'Error while fetching'; + throw { + message: + 'Error Reading :: Ensure www.airtable.com/ is accessible. Refer https://bit.ly/3x0OdXI for details', + }; }); return { @@ -103,7 +120,10 @@ async function read() { baseInfo: info.baseInfo, }; } else { - throw 'Please initialize first!'; + throw { + message: + 'Error Initializing :: please try again !!', + }; } } @@ -149,11 +169,17 @@ async function readView(viewId) { return response.data; }) .catch(() => { - throw 'Error while fetching'; + throw { + message: + 'Error Reading View :: Ensure www.airtable.com/ is accessible. Refer https://bit.ly/3x0OdXI for details', + }; }); return { view: resreq.data }; } else { - throw 'Please initialize first!'; + throw { + message: + 'Error Initializing :: please try again !!', + }; } } @@ -192,7 +218,10 @@ async function readTemplate(templateId) { return response.data; }) .catch(() => { - throw 'Error while fetching'; + throw { + message: + 'Error Fetching :: Ensure www.airtable.com/templates/featured/ is accessible.', + }; }); return { template: resreq }; } From 222246ae72e9a922b7edd17e210b4bb05c3e13e3 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 27 Dec 2022 17:50:42 +0300 Subject: [PATCH 3/5] fix: disconnect from socket if modal closed Signed-off-by: mertmit --- packages/nc-gui/components/dlg/AirtableImport.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/dlg/AirtableImport.vue b/packages/nc-gui/components/dlg/AirtableImport.vue index 12cd859e98..d27498af69 100644 --- a/packages/nc-gui/components/dlg/AirtableImport.vue +++ b/packages/nc-gui/components/dlg/AirtableImport.vue @@ -45,8 +45,6 @@ const enableAbort = ref(false) let socket: Socket | null -let socketInterval: NodeJS.Timer - const syncSource = ref({ id: '', type: 'Airtable', @@ -275,10 +273,10 @@ onMounted(async () => { onBeforeUnmount(() => { if (socket) { - socket.removeAllListeners() + socket.off('disconnect') socket.disconnect() + socket.removeAllListeners() } - clearInterval(socketInterval) }) From e49d9355d44f2ace26e8fd839d33e2788a0c4c05 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 27 Dec 2022 17:51:24 +0300 Subject: [PATCH 4/5] fix: loading indicator persist even if isLoading false Signed-off-by: mertmit --- packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue b/packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue index 8e050add53..e2f0c33595 100644 --- a/packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue +++ b/packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue @@ -75,7 +75,7 @@ function onEdit(targetKey: number, action: 'add' | 'remove' | string) {
-
+
{{ $t('general.loading') }} From bcfb68b6fba86a508b22b450c3f34a35bbe86e3e Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 27 Dec 2022 17:52:13 +0300 Subject: [PATCH 5/5] fix: add timeout before starting job to allow socket instance to receive all messages Signed-off-by: mertmit --- .../src/lib/meta/api/sync/importApis.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/sync/importApis.ts b/packages/nocodb/src/lib/meta/api/sync/importApis.ts index 5b3d05bcb9..92ab241117 100644 --- a/packages/nocodb/src/lib/meta/api/sync/importApis.ts +++ b/packages/nocodb/src/lib/meta/api/sync/importApis.ts @@ -107,14 +107,17 @@ export default ( baseURL = `http://localhost:${process.env.PORT || 8080}`; } - NocoJobs.jobsMgr.add(AIRTABLE_IMPORT_JOB, { - id: req.params.syncId, - ...(syncSource?.details || {}), - projectId: syncSource.project_id, - baseId: syncSource.base_id, - authToken: token, - baseURL, - }); + setTimeout(() => { + NocoJobs.jobsMgr.add(AIRTABLE_IMPORT_JOB, { + id: req.params.syncId, + ...(syncSource?.details || {}), + projectId: syncSource.project_id, + baseId: syncSource.base_id, + authToken: token, + baseURL, + }); + }, 1000); + jobs[req.params.syncId] = { last_message: { msg: 'Sync started',