Skip to content

Commit

Permalink
fix(cdp): Invocation loop (#23331)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Jun 28, 2024
1 parent a27381d commit 7a4acb9
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions plugin-server/src/cdp/cdp-consumers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,20 @@ export class CdpOverflowConsumer extends CdpConsumerBase {
return await runInstrumentedFunction({
statsKey: `cdpConsumer.handleEachBatch.executeOverflowedFunctions`,
func: async () => {
const results = (
await Promise.all(
invocationGlobals.map((item) => {
return this.runManyWithHeartbeat(item.hogFunctionIds, (hogFunctionId) =>
this.hogExecutor.executeFunction(item.globals, hogFunctionId)
)
})
const invocations = invocationGlobals
.map((item) =>
item.hogFunctionIds.map((hogFunctionId) => ({
globals: item.globals,
hogFunctionId,
}))
)
)
.flat()
.filter((x) => !!x) as HogFunctionInvocationResult[]

const results = (
await this.runManyWithHeartbeat(invocations, (item) =>
this.hogExecutor.executeFunction(item.globals, item.hogFunctionId)
)
).filter((x) => !!x) as HogFunctionInvocationResult[]

this.hogWatcher.currentObservations.observeResults(results)
return results
Expand Down

0 comments on commit 7a4acb9

Please sign in to comment.