Skip to content

Commit

Permalink
Merge pull request #469 from PrefectHQ/fix/fixed-event-polling
Browse files Browse the repository at this point in the history
Fix: Use static polling interval for events
  • Loading branch information
pleek91 authored Mar 18, 2024
2 parents 179161b + 3bd1aad commit b895bb9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/factories/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function dataFactory(runId: string, callback: DataCallback) {

// todo: need a global way of stopping this when the graph is stopped
function stop(): void {
clearInterval(interval)
clearTimeout(interval)
}

return {
Expand Down
5 changes: 2 additions & 3 deletions src/factories/eventData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MaybeRefOrGetter, toValue } from 'vue'
import { getIntervalForDataSize } from '@/factories/data'
import { RunGraphEvent, RunGraphFetchEventsOptions } from '@/models'
import { waitForConfig } from '@/objects/config'
import { waitForRunData } from '@/objects/nodes'
Expand Down Expand Up @@ -28,13 +27,13 @@ export async function eventDataFactory(
}

if (!runGraphData.end_time) {
interval = setTimeout(() => start(), getIntervalForDataSize(runGraphData))
interval = setTimeout(() => start(), config.fetchEventsInterval)
}
}

// todo: need a global way of stopping this when the graph is stopped
function stop(): void {
clearInterval(interval)
clearTimeout(interval)
}

return {
Expand Down
1 change: 1 addition & 0 deletions src/models/RunGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export type RunGraphConfig = {
runId: string,
fetch: RunGraphFetch,
fetchEvents?: RunGraphFetchEvents,
fetchEventsInterval?: number,
animationDuration?: number,
styles?: RunGraphStyles,
disableAnimationsThreshold?: number,
Expand Down
1 change: 1 addition & 0 deletions src/objects/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const defaults: Omit<RequiredGraphConfig, 'runId' | 'fetch'> = {
disableAnimationsThreshold: 500,
disableEdgesThreshold: 500,
fetchEvents: () => [],
fetchEventsInterval: 30000,
styles: {
colorMode: 'dark',
rowGap: 24,
Expand Down

0 comments on commit b895bb9

Please sign in to comment.