Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: date issue with single query

mertmite4a9faef775c
diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts
index d04eb68584..7752b19161 100644
--- a/packages/nocodb/src/db/BaseModelSqlv2.ts
+++ b/packages/nocodb/src/db/BaseModelSqlv2.ts
@@ -5677,7 +5677,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
}
}
- const batchSize = 10;
+ const batchSize = 15;
// Process attachments in batches
for (let i = 0; i < allAttachments.length; i += batchSize) {
@@ -5999,6 +5999,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
: null;
// Pre-compile regex patterns to avoid repeated compilation
+ // the pre-compiled patterns have mutable `lastIndex` property that we use below, so it cannot be made global to avoid race condition
const isoRegex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/g;
const datetimeRegex =
/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:[+-]\d{2}:\d{2})?/g;
diff --git a/packages/nocodb/src/models/PresignedUrl.ts b/packages/nocodb/src/models/PresignedUrl.ts
index f819648d9c..67e1d0299b 100644
--- a/packages/nocodb/src/models/PresignedUrl.ts
+++ b/packages/nocodb/src/models/PresignedUrl.ts
@@ -297,11 +297,11 @@ export default class PresignedUrl {
) {
if (!data) return;
- const promises = [];
+ const allItems = [];
try {
for (const d of Array.isArray(data) ? data : [data]) {
- if (!ncIsObject(d)) {
+ if (!ncIsObject(d) || !d.meta) {
continue;
}
@@ -312,15 +312,20 @@ export default class PresignedUrl {
(d.meta as Record<string, any>).icon &&
(d.meta as Record<string, any>).iconType === IconType.IMAGE
) {
- promises.push(
- PresignedUrl.signAttachment({
- attachment: (d.meta as Record<string, any>).icon,
- }),
- );
+ allItems.push({
+ attachment: (d.meta as Record<string, any>).icon,
+ });
}
}
- await Promise.all(promises);
+ const batchSize = 15;
+ for (let i = 0; i < allItems.length; i += batchSize) {
+ const batch = allItems.slice(i, i + batchSize);
+ const batchPromises = batch.map(
+ (item) => PresignedUrl.signAttachment(item).catch(() => {}), // Ignore individual failures
+ );
+ await Promise.all(batchPromises);
+ }
} catch (e) {
logger.error('Error signing meta icon image', e);
}