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

x/pkgsite/cmd/pkgsite: tests consistently failing with TempDir RemoveAll cleanup errors on windows as of CL 559615 #65545

Closed
bcmills opened this issue Feb 6, 2024 · 2 comments
Labels
OS-Windows Soon This needs action soon. (recent regressions, service outages, unusual time-sensitive situations)
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Feb 6, 2024

Go version

6f44cc8

Output of go env in your module/workspace:

N/A

What did you do?

https://build.golang.org/log/292d4f122d2f2eab97f2bc7e5c07570c4311f17f

What did you see happen?

--- FAIL: TestServer (6.89s)
    testing.go:1231: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestServer2537943436\001: The process cannot access the file because it is being used by another process.
FAIL
FAIL	golang.org/x/pkgsite/cmd/pkgsite	7.092s

What did you expect to see?

All tests should be passing.

I think this is just a missed Closed call on a file opened in extractReadme.

@bcmills bcmills added OS-Windows Soon This needs action soon. (recent regressions, service outages, unusual time-sensitive situations) labels Feb 6, 2024
@gopherbot gopherbot added this to the Unreleased milestone Feb 6, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/562176 mentions this issue: internal/fetch: close directory file in defer in extractReadme

@eduzgun
Copy link

eduzgun commented Jun 15, 2024

Try running this

t.Cleanup(func() {
		runtime.GC()
})

which will trigger a manual garbage collection. If there are any file handles that were opened but not explicitly closed, the garbage collector will close them once it sees they are no longer being referenced. By calling runtime.GC(), you ensure any lingering open file handles are closed before TempDir naturally tries to clean itself up. It doesn't affect the logic in the test because t.cleanup() will run after the test completes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-Windows Soon This needs action soon. (recent regressions, service outages, unusual time-sensitive situations)
Projects
None yet
Development

No branches or pull requests

3 participants