Skip to content

Conversation

johnsimons
Copy link
Member

@johnsimons johnsimons commented Oct 8, 2025

This PR re-enabled the latest Windows CI runner.

In this PR, we remove the auto-refresh from the stores and instead create a composable that uses onmount and unmounted to start and stop the auto-refresh, which is then bound to a component.

We also standardised on vueuse lib for things like throttling and debouncing, ... This library is more in line with Vue development practices instead of lodash and other libs.

I also took this opportunity to add Vue DevTools, which helps with debugging Vue apps in the browser. This can be seen as an extension of the browser's developer tools. This is only available when running in Vite locally.

onMounted(async () => {
await useServiceControl();
useServiceControlAutoRefresh();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this initialisation of background refresh tasks explicit so that they get cleaned up as part of unmount.

);
onUnmounted(() => {
dataRetriever.updateTimeout(null);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just to stop the autorefresh; it is no longer needed. We do this differently now.

onUnhandledRequest: (request, { error }) => {
console.log("Unhandled %s %s", request.method, request.url);
error();
onUnhandledRequest: (request) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to reduce this to just a warning, given that we don't really need to blow up.


return (
"default-src 'none';" +
"default-src 'self';" +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to enable the Vue Devtools to render correctly.
This CSP is only for dev.

globals: true,
clearMocks: true,
css: true,
testTimeout: 10000,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to slightly increase the timeout after reviewing the times on the CI.
They seem to take longer randomly.

@johnsimons johnsimons marked this pull request as ready for review October 9, 2025 02:35
const historyPeriodStore = useMonitoringHistoryPeriodStore();

const getMemoisedEndpointDetails = memoiseOne(MonitoringEndpoints.useGetEndpointDetails);
const getMemoisedEndpointDetails = useMemoize(MonitoringEndpoints.useGetEndpointDetails);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i read https://vueuse.org/core/useMemoize/ to see if it's different to memoiseOne, since memoiseOne is specifically designed to only ever keep one invocation cached, and it looks like it's the same? A bit unclear... but shouldn't really matter either way

const isLoading = ref(false);
const dataRetriever = useAutoRefresh(
throttle(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this throttle carried through? I think it was intended to stop another refresh from happening before the current running one finished

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't carried it over on purpose, I honestly don't remmeber why I added it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new implementation, there shouldn't be 2 refreshes happening at the same time anyway

mockServer.listen({
onUnhandledRequest: (request, { error }) => {
console.log("Unhandled %s %s", request.method, request.url);
error();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't need to error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why.
At the moment, with the error, it just means that we forgot to mock a response, but that should fail a test. If that is true, then why do we need to error at all?
If the tests are well written, the test will fail. Does this make sense @PhilBastian ?

@PhilBastian PhilBastian requested a review from cquirosj October 14, 2025 05:36
@johnsimons johnsimons merged commit d307c09 into john/flaky Oct 14, 2025
5 checks passed
@johnsimons johnsimons deleted the john/refresh_v2 branch October 14, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants