Use async-safe bracket for withTempFileName
If `withTempFileName` receives an asynchronous exception (e.g. a canceled async), the bracket cleanup handler will attempt to remove the temporary file. This can fail with an IO exception. Regular bracket then throws that IO exception, swallowing the asynchronous exception. To calling code, this appears no different from an IO exception thrown from the body, and it won't be able to tell that it should be exiting promptly. This manifests concretely during temporary file clean-up of `asyncFetchPackages` on Windows (seen during unit testing in CI), where temporary file removal fails (on GHC 8.4), which leads to `concurrently` failing to cancel the outstanding download because it's handled like a regular download failure.
Please register or sign in to comment