Skip to content

Conversation

@rezk2ll
Copy link
Contributor

@rezk2ll rezk2ll commented Nov 12, 2025

issue

When a query fails, it does not update the store, which causes the OlderThan fetch policy to always return true, and this will cause an infinite loop when trying to fetch the same query.

olderThan: delay => queryState => {
  if (!queryState || !queryState.lastUpdate) {
    return true
  } else {
    const elapsed = Date.now() - queryState.lastUpdate
    return elapsed > delay
  }
},

this is used everywhere, especially in the useInstanceInfo hook,

const buildSettingsByIdQuery = id => ({
  definition: Q('io.cozy.settings').getById(id),
  options: {
    as: `io.cozy.settings/${id}`,
    fetchPolicy: CozyClient.fetchPolicies.olderThan(
      DEFAULT_CACHE_TIMEOUT_QUERIES
    ),
    singleDocData: true
  }
})

@Crash--
Copy link
Contributor

Crash-- commented Nov 12, 2025

This is an interesting finding.

I don’t know yet if this is the right fix because updating the lastUpdated if the request fail sounds wrong to me. But maybe checking the lastUpdateError in the policy is better.

But why on earth do we have component that re render infinitely?! Is it because of this hook? Or is it related to something else?

@rezk2ll rezk2ll force-pushed the fix/erro-state-query branch from 673a8cf to 973fe90 Compare November 13, 2025 08:32
@rezk2ll
Copy link
Contributor Author

rezk2ll commented Nov 13, 2025

This is an interesting finding.

I don’t know yet if this is the right fix because updating the lastUpdated if the request fail sounds wrong to me. But maybe checking the lastUpdateError in the policy is better.

But why on earth do we have component that re render infinitely?! Is it because of this hook? Or is it related to something else?

I updated the PR ( to a less ugly solution ), but i still haven't figured why the components or the hook is looping YET.

@rezk2ll rezk2ll force-pushed the fix/erro-state-query branch from 973fe90 to debc5e7 Compare November 13, 2025 08:34
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.

3 participants