Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove ctx.cloud.reset in tests, handle infinite loop in stale results #22483

Conversation

tgriesser
Copy link
Member

Related to #21250

Additional details

Correctly fixes tests failing due to the introduction of the new queries on the specs page, properly handles an infinite loop that was occurring when an incomplete response was sent back for a stale fetch result. This would cause an infinite re-fetch loop while the server was looking to fulfill the stale value. Instead, now if we detect this situation we clear the urql cache in both the electron process and the client.

Steps to test

Existing tests should be passing with only minor, expected modifications

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 23, 2022

Thanks for taking the time to open a PR!

@tgriesser tgriesser marked this pull request as ready for review June 23, 2022 17:21
})
},
invalidateCache () {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not super happy with the naming of this, might change to onInvalidateCache, and centralize the client & server invalidation calls as like ctx.invalidateGraphQLCache().

@cypress
Copy link

cypress bot commented Jun 23, 2022



Test summary

37555 0 454 0Flakiness 4


Run details

Project cypress
Status Passed
Commit 7415132
Started Jun 23, 2022 9:10 PM
Ended Jun 23, 2022 9:29 PM
Duration 18:20 💡
OS Linux Debian - 10.11
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

e2e/origin/validation.cy.ts Flakiness
1 cy.origin > successes > uses cy.origin twice
next.cy.ts Flakiness
1 Working with next-12.1.6 > should detect new spec
cypress/proxy-logging.cy.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second
2 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Comment on lines +67 to +70
if (toPush.invalidateCache) {
cache.invalidate({ __typename: 'Query' })
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm probably overthinking this, but is there any potential perf advantage to first checking pushFragment for any entries with invalidateCache and, if there are any, filtering out all entries prior to the last one since they'll just get invalidated as we progress through this loop?

Of course there's a real possibility I just don't understand the cache structure here, or maybe there won't ever be enough entries to make this an issue?

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 think we'd ever expect to get into a situation where we'd see both here

* by an additional fetch to the server. This means we've gotten into a bad state
* and we need to clear both the server & client side cache
*/
invalidateCache: () => any
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever return anything "actionable" from this function? Should it be void? Or is there a vision that there may be circumstances where this could be chained off of?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah it should be void, will updated

packages/data-context/src/sources/CloudDataSource.ts Outdated Show resolved Hide resolved
@@ -52,10 +54,12 @@ describe('CloudDataSource', () => {
it('returns immediately with { data: null } when no user is defined', () => {
getUserStub.returns(null)
const result = cloudDataSource.executeRemoteGraphQL({
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels pretty repetitive, any advantage to pulling out into a reusable beforeEach or function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I guess we could add a little helper fn here, though I'm always wary of doing too much abstracting where this is the actual function being tested, comes at the cost of indirection - it was simple enough to just do a find/replace here

@tgriesser tgriesser requested a review from a team as a code owner June 23, 2022 20:30
@tgriesser tgriesser requested review from chrisbreiding and removed request for a team June 23, 2022 20:30
@tgriesser tgriesser merged commit 17a37cb into muaz/CLOUD-577-spec-list-display-latest-runs Jun 23, 2022
@tgriesser tgriesser deleted the tgriesser/fix/cloud-cache-fixes branch June 23, 2022 21:56
tgriesser added a commit that referenced this pull request Jun 24, 2022
…esser/CLOUD-577-spec-list-display-latest-runs-batching

* muaz/CLOUD-577-spec-list-display-latest-runs:
  fix: Update "Request Access" button state after requesting access (ACI) (#22499)
  feat: Support "Queued" latest run status (#22497)
  fix: remove ctx.cloud.reset in tests, handle infinite loop in stale results (#22483)
  chore: add reporter webpack to gulp watch script (#22386)
  fix: Increase timeout for npm-webpack-dev-server tests (#22489)
  fix: Time out unmatched prerequests in proxy to avoid leaking memory (#22462)
  fix: Sort results in findCrossOriginLogs test helper to deterministic (#22481)
  fix: memory leak caused by storing base64 encoded files recieved by CDP `Network.requestWillBeSent` (#22460)
  fix: Improve cross-origin cookie handling (#22320)
  feat: Add button to clear value from search fields (#22202)
  chore: Add test to verify settings panels are collapsed by default (#22382)
  fix: process_profiler follow up work for v10 (#22363)
  chore: Update Chrome (stable) to 103.0.5060.53 (#22441)
  refactor: use design system windicss config (#21503)
  chore: update readme logo (#22433)
  chore: Update Chrome (beta) to 103.0.5060.53 (#22351)
  chore: updating version (#22432)
  Trigger Build
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.

None yet

3 participants