@@ -2,6 +2,7 @@ import { WorkerPool } from "gatsby-worker"
22import { chunk } from "lodash"
33import reporter from "gatsby-cli/lib/reporter"
44import { cpuCoreCount } from "gatsby-core-utils"
5+ import { Span } from "opentracing"
56
67import { IGroupedQueryIds } from "../../services"
78import { initJobsMessagingInMainProcess } from "../jobs/worker-messaging"
@@ -46,16 +47,27 @@ function handleRunQueriesInWorkersQueueError(e: Error): never {
4647export async function runQueriesInWorkersQueue (
4748 pool : GatsbyWorkerPool ,
4849 queryIds : IGroupedQueryIds ,
49- chunkSize = queriesChunkSize
50+ opts ?: {
51+ chunkSize ?: number
52+ parentSpan ?: Span
53+ }
5054) : Promise < void > {
5155 const activity = reporter . createProgress (
5256 `run queries in workers` ,
53- queryIds . staticQueryIds . length + queryIds . pageQueryIds . length
57+ queryIds . staticQueryIds . length + queryIds . pageQueryIds . length ,
58+ 0 ,
59+ { parentSpan : opts ?. parentSpan }
5460 )
5561 activity . start ( )
5662 try {
57- const staticQuerySegments = chunk ( queryIds . staticQueryIds , chunkSize )
58- const pageQuerySegments = chunk ( queryIds . pageQueryIds , chunkSize )
63+ const staticQuerySegments = chunk (
64+ queryIds . staticQueryIds ,
65+ opts ?. chunkSize ?? queriesChunkSize
66+ )
67+ const pageQuerySegments = chunk (
68+ queryIds . pageQueryIds ,
69+ opts ?. chunkSize ?? queriesChunkSize
70+ )
5971
6072 pool . all . setComponents ( )
6173
@@ -90,8 +102,11 @@ export async function runQueriesInWorkersQueue(
90102 }
91103}
92104
93- export async function mergeWorkerState ( pool : GatsbyWorkerPool ) : Promise < void > {
94- const activity = reporter . activityTimer ( `Merge worker state` )
105+ export async function mergeWorkerState (
106+ pool : GatsbyWorkerPool ,
107+ parentSpan ?: Span
108+ ) : Promise < void > {
109+ const activity = reporter . activityTimer ( `Merge worker state` , { parentSpan } )
95110 activity . start ( )
96111
97112 for ( const { workerId } of pool . getWorkerInfo ( ) ) {
0 commit comments