Fix artifact upload chunk timeout logic + update tests #1774
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking at CI output for:
We had an issue/race where we were trying to do stuff after the test completed:
Turns out we had a few errors in our tests and I also discovered we were not handling our timeout logic correctly:
The problematic area of the timeout logic was that it was throwing an error within the
setTimeout
block, which is outside the promise area and went unhandled. To remedy this (and avoid other leaky async code) I swapped it with asetInterval
wrapped in a Promise that would check the last chunk upload. Then, I gave this function and the blob upload anAbortController
so we can quit everything when we want to. Then, the main await is aPromise.race
where we always abort after the first promise resolves.As for the tests, we were incorrectly mocking over the logic we were testing and throwing immediately. I also took the liberty of updating the rest of the tests since there was a lot of duplication that made each test harder to reason about.