@@ -5,7 +5,7 @@ import { getErrorMessage } from '@sim/utils/errors'
55import { and , desc , eq , lt , or , type SQL , sql } from 'drizzle-orm'
66import { type NextRequest , NextResponse } from 'next/server'
77import { getSession } from '@/lib/auth'
8- import { MATERIALIZE_CONCURRENCY , mapWithConcurrency } from '@/lib/core/utils/concurrency'
8+ import { mapWithConcurrency } from '@/lib/core/utils/concurrency'
99import { formatCsvValue , toCsvRow } from '@/lib/core/utils/csv'
1010import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
1111import { materializeExecutionDataForDisplay } from '@/lib/logs/execution/trace-store'
@@ -14,7 +14,8 @@ import { expandFolderIdsWithDescendants } from '@/lib/logs/folder-expansion'
1414import { checkWorkspaceAccess } from '@/lib/workspaces/permissions/utils'
1515
1616const logger = createLogger ( 'LogsExportAPI' )
17- const LOG_EXPORT_PAGE_SIZE = 1
17+ const LOG_EXPORT_PAGE_SIZE = 100
18+ const LOG_EXPORT_MATERIALIZE_CONCURRENCY = 1
1819
1920export const revalidate = 0
2021
@@ -119,18 +120,25 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
119120
120121 if ( ! rows . length ) break
121122
122- for ( let chunkStart = 0 ; chunkStart < rows . length ; chunkStart += MATERIALIZE_CONCURRENCY ) {
123- const chunk = rows . slice ( chunkStart , chunkStart + MATERIALIZE_CONCURRENCY )
124- const materialized = await mapWithConcurrency ( chunk , MATERIALIZE_CONCURRENCY , ( row ) =>
125- materializeExecutionDataForDisplay (
126- row . executionData as Record < string , unknown > | null ,
127- {
128- workspaceId : params . workspaceId ,
129- workflowId : row . workflowId ,
130- executionId : row . executionId ,
131- userId : session . user . id ,
132- }
133- )
123+ for (
124+ let chunkStart = 0 ;
125+ chunkStart < rows . length ;
126+ chunkStart += LOG_EXPORT_MATERIALIZE_CONCURRENCY
127+ ) {
128+ const chunk = rows . slice ( chunkStart , chunkStart + LOG_EXPORT_MATERIALIZE_CONCURRENCY )
129+ const materialized = await mapWithConcurrency (
130+ chunk ,
131+ LOG_EXPORT_MATERIALIZE_CONCURRENCY ,
132+ ( row ) =>
133+ materializeExecutionDataForDisplay (
134+ row . executionData as Record < string , unknown > | null ,
135+ {
136+ workspaceId : params . workspaceId ,
137+ workflowId : row . workflowId ,
138+ executionId : row . executionId ,
139+ userId : session . user . id ,
140+ }
141+ )
134142 )
135143
136144 for ( let index = 0 ; index < chunk . length ; index ++ ) {
0 commit comments