Page MenuHomeElementl

Fix apollo cache reset race condition
ClosedPublic

Authored by sashank on Nov 25 2020, 6:19 PM.

Details

Summary

Previously, we were doing a refetch on the root repositories query when we clicked the reload button. However, this isn't needed since we're already doing an apollo.resetStore when reloading a location. This diff removes the unnecessary refetch.

There is also a race condition with the new network only query used in the repository locations page. We need to refetch the network only query, but also need to reset the store. Apollo doesn't like when both things happen at the same time and throws an error. To mitigate this, I added a small timeout on the network-only refetch, but would appreciate any suggestions on a better/more correct way to fix this.

Finally, I've also added a toast that appears when reloading and hitting an error. We would previously only show a toast on reload success.

Test Plan

Reload repository locations in Dagit

Diff Detail

Repository
R1 dagster
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sashank added inline comments.
js_modules/dagit/src/workspace/WorkspaceRepositoryLocationsRoot.tsx
122–127

This is the problematic refetch

dish added inline comments.
js_modules/dagit/src/nav/LeftNav.tsx
56

Can refetch now be removed from the workspace context return value? Or is it still needed elsewhere?

js_modules/dagit/src/nav/RepositoryPicker.test.tsx
77–78

Looks like nothing's being tested here anymore -- should the test be removed?

js_modules/dagit/src/workspace/WorkspaceRepositoryLocationsRoot.tsx
124

Add a comment to explain the delay?

This revision is now accepted and ready to land.Nov 25 2020, 6:52 PM
js_modules/dagit/src/nav/RepositoryPicker.test.tsx
77–78

I guess it tests that there's no error, not sure if that's valuable

js_modules/dagit/src/nav/LeftNav.tsx
56

looks like it's only being used in test – will remove in a new diff

This revision was landed with ongoing or failed builds.Nov 25 2020, 10:59 PM
This revision was automatically updated to reflect the committed changes.