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

Move http cache writing to cacheitem. #4919

Merged
merged 3 commits into from
May 17, 2023

Conversation

nathanhammond
Copy link
Contributor

The HTTP cache creates its own tar files that aren't cacheitem. This migrates them to use cacheitem, same as filesystem cache.

@vercel
Copy link

vercel bot commented May 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-kitchensink-blog 🔄 Building (Inspect) May 17, 2023 0:34am
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2023 0:34am
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-cra-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-designsystem-docs ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-gatsby-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-native-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-nonmonorepo ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-svelte-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-tailwind-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am
examples-vite-web ⬜️ Ignored (Inspect) May 17, 2023 0:34am

@vercel
Copy link

vercel bot commented May 12, 2023

Someone is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor Author

@nathanhammond nathanhammond left a comment

Choose a reason for hiding this comment

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

Reviewer's guide!

@@ -31,7 +31,7 @@ type CacheItem struct {
tw *tar.Writer
zw io.WriteCloser
fileBuffer *bufio.Writer
handle io.Reader
handle interface{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Caches are Reader | Writer | Closer but you can't express that in Go. So this goes to interface{} and each place that needs it does a type assertion.

#4634 made this partially generic, this finishes the work.

// log.Printf("caching file %v", file)
if err := cache.storeFile(tw, file); err != nil {
log.Printf("[ERROR] Error uploading artifact %s to HTTP cache due to: %s", file, err)
// TODO(jaredpalmer): How can we cancel the request at this point?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is fixed by using the channel. Previously failing here didn't actually blow up the artifact.

}
}
}
func (cache *httpCache) write(w io.WriteCloser, anchor turbopath.AbsoluteSystemPath, files []turbopath.AnchoredSystemPath, cacheErrorChan chan error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now 1:1 with cache_fs's implementation.

@nathanhammond nathanhammond force-pushed the cache-http-write branch 3 times, most recently from 528d6fd to b1f9352 Compare May 17, 2023 12:31
@nathanhammond
Copy link
Contributor Author

The CI test run that confirms cross-platform compat for cacheitem is here: https://github.com/nathanhammond/turbo/actions/runs/5002277231

@gsoltis gsoltis merged commit 9f73619 into vercel:main May 17, 2023
@nathanhammond nathanhammond deleted the cache-http-write branch May 17, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants