@@ -152,7 +152,7 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
152152 const needsMaterialize =
153153 params . details === 'full' && ( params . includeFinalOutput || params . includeTraceSpans )
154154
155- const formattedLogs = await mapWithConcurrency ( data , MATERIALIZE_CONCURRENCY , async ( log ) => {
155+ const buildBase = ( log : ( typeof data ) [ number ] ) => {
156156 const result : any = {
157157 id : log . id ,
158158 workflowId : log . workflowId ,
@@ -174,27 +174,36 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
174174 description : log . workflowDescription ,
175175 deleted : ! log . workflowName ,
176176 }
177-
178- if ( needsMaterialize && log . executionData ) {
179- const execData = ( await materializeExecutionData (
180- log . executionData as Record < string , unknown > | null ,
181- {
182- workspaceId : log . workspaceId ,
183- workflowId : log . workflowId ,
184- executionId : log . executionId ,
185- }
186- ) ) as any
187- if ( params . includeFinalOutput && execData . finalOutput ) {
188- result . finalOutput = execData . finalOutput
189- }
190- if ( params . includeTraceSpans && execData . traceSpans ) {
191- result . traceSpans = execData . traceSpans
192- }
193- }
194177 }
195178
196179 return result
197- } )
180+ }
181+
182+ // Only run the bounded-concurrency materialization when the response actually
183+ // needs object-storage reads; otherwise a plain synchronous map avoids the
184+ // per-row worker/promise overhead.
185+ const formattedLogs = needsMaterialize
186+ ? await mapWithConcurrency ( data , MATERIALIZE_CONCURRENCY , async ( log ) => {
187+ const result = buildBase ( log )
188+ if ( log . executionData ) {
189+ const execData = ( await materializeExecutionData (
190+ log . executionData as Record < string , unknown > | null ,
191+ {
192+ workspaceId : log . workspaceId ,
193+ workflowId : log . workflowId ,
194+ executionId : log . executionId ,
195+ }
196+ ) ) as any
197+ if ( params . includeFinalOutput && execData . finalOutput ) {
198+ result . finalOutput = execData . finalOutput
199+ }
200+ if ( params . includeTraceSpans && execData . traceSpans ) {
201+ result . traceSpans = execData . traceSpans
202+ }
203+ }
204+ return result
205+ } )
206+ : data . map ( buildBase )
198207
199208 const limits = await getUserLimits ( userId )
200209
0 commit comments