Skip to content

Correctly reset chunk during artifact upload on retry#458

Merged
konradpabjan merged 3 commits into
masterfrom
konradpabjan/fix-artifact-readstream
May 14, 2020
Merged

Correctly reset chunk during artifact upload on retry#458
konradpabjan merged 3 commits into
masterfrom
konradpabjan/fix-artifact-readstream

Conversation

@konradpabjan
Copy link
Copy Markdown
Contributor

@konradpabjan konradpabjan commented May 14, 2020

Fixes weird retry behavior reported here: actions/upload-artifact#71

If there is a connection error or timeout, the readstream should be successfully reset to the beginning so the subsequent retries should not give the same error.

actions/cache recently fixed this issue in a PR so this is largely copying over the same fix: actions/cache#305

strategy:
matrix:
runs-on: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: [ubuntu-latest, windows-latest, macos-latest]
Copy link
Copy Markdown
Contributor Author

@konradpabjan konradpabjan May 14, 2020

Choose a reason for hiding this comment

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

All of our public documentation has macos so I'm changing it just for consistency. A GitHub user actually brought this up in one of my other PRs so I'm looking out for this now.

https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources

https://github.com/actions/virtual-environments#available-environments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These are case-insensitive and macOS is more correct than macos based on how Apple names it

@@ -1,13 +1,21 @@
name: artifact-unit-tests
on: push
on:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also updating these to match our filters in unit-tests.yml

Copy link
Copy Markdown
Contributor

@joshmgross joshmgross left a comment

Choose a reason for hiding this comment

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

LGTM!

passThrough.end(buffer)
uploadStream = passThrough
openUploadStream = () => {
const passThrough = new stream.PassThrough()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I realize this was the existing code, but why do we need a stream that is both readable and writable for upload?

Copy link
Copy Markdown
Contributor Author

@konradpabjan konradpabjan May 14, 2020

Choose a reason for hiding this comment

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

It's an implementation detail, we have an in-memory buffer and we have to convert it somehow to a readable stream. A passthrough stream is used to get the job done without any extra pipping or secondary streams. During the actual upload, it's treated only as a readable stream so it makes no difference.

I think this is where I originally got the idea from: https://stackoverflow.com/questions/16038705/how-to-wrap-a-buffer-as-a-stream2-readable-stream

I recall experimenting with a bunch of other techniques but they all ended up being considerably more complex.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@konradpabjan konradpabjan merged commit 628f82f into master May 14, 2020
@konradpabjan konradpabjan deleted the konradpabjan/fix-artifact-readstream branch May 14, 2020 20:18
at-wat pushed a commit to at-wat/actions-toolkit that referenced this pull request Aug 31, 2023
* Correctly reset chunk during artifact upload on retry

* Update workflow

* Implementation details around the passthrough stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants