Skip to content

Commit

Permalink
fix: Test flake when installing yarn dependencies on MacOS (#436)
Browse files Browse the repository at this point in the history
This fixes #433 - a test flake in E2E (intermittent `ESOCKETTIMEDOUT` errors on MacOS).

The main issue is that, occasionally, for very large dependencies (like `@material-ui/icons`) - yarn can actually time out! We researched this in-depth in v1: https://github.com/coder/m/pull/10040 and fixed it successfully there, by increasing the timeout for yarn.

However, this also highlighted the fact that our `node_modules` caching behavior wasn't correct - we should very rarely see a timeout issue like this, because `@material-ui/icons` should be cached.

It turns out that we weren't falling back to the latest cached `node_modules` if there was a miss - so anytime the lock file changed, we'd  invalidate the cache, and not restore the previous one. This can be improved by using the [`restore-keys`](https://github.com/coder/m/pull/10040) parameter of the [`@actions/cache`](https://github.com/actions/cache)... and in fact we already do this for the `go` dependencies.

So this fix does two things:
- Improve the caching behavior, such that we should rarely have to install `@material-ui/icons` (and other large dependencies) 
- When we do have to install, update the timeout so that we can avoid random `ESOCKETTIMEDOUT` errors
  • Loading branch information
bryphe-coder committed Mar 14, 2022
1 parent 58a358b commit 20faf89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install node_modules
run: ./scripts/yarn_install.sh
Expand Down Expand Up @@ -108,6 +110,8 @@ jobs:
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install node_modules
run: ./scripts/yarn_install.sh
Expand Down Expand Up @@ -250,6 +254,8 @@ jobs:
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
# Go is required for uploading the test results to datadog
- uses: actions/setup-go@v2
Expand Down Expand Up @@ -312,6 +318,8 @@ jobs:
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
# Go is required for uploading the test results to datadog
- uses: actions/setup-go@v2
Expand Down
1 change: 1 addition & 0 deletions site/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
network-timeout 300000

0 comments on commit 20faf89

Please sign in to comment.