diff --git a/ui/src/Components/Fetcher/index.js b/ui/src/Components/Fetcher/index.js index 53e0e1896..acaae31bd 100644 --- a/ui/src/Components/Fetcher/index.js +++ b/ui/src/Components/Fetcher/index.js @@ -54,7 +54,8 @@ const Fetcher = observer( }; componentDidMount() { - this.fetchIfIdle(); + // start first fetch once the browser is done doing busy loading + window.requestAnimationFrame(this.fetchIfIdle); this.timer = setInterval(this.timerTick, 1000); } diff --git a/ui/src/Components/Fetcher/index.test.js b/ui/src/Components/Fetcher/index.test.js index 365381f5e..9b3507558 100644 --- a/ui/src/Components/Fetcher/index.test.js +++ b/ui/src/Components/Fetcher/index.test.js @@ -29,9 +29,12 @@ beforeEach(() => { settingsStore = new Settings(); settingsStore.fetchConfig.config.interval = 30; + + jest.spyOn(window, "requestAnimationFrame").mockImplementation(cb => cb()); }); afterEach(() => { + window.requestAnimationFrame.mockRestore(); jest.clearAllTimers(); jest.clearAllMocks(); jest.restoreAllMocks();