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

feat: adjust shard size #908

Merged
merged 8 commits into from
Sep 7, 2023
Merged

feat: adjust shard size #908

merged 8 commits into from
Sep 7, 2023

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Sep 6, 2023

As discussed in #764 and calculated in https://observablehq.com/@gozala/w3up-shard-size, this PR adjusts the upload-client to shard on a CAR size of <= 133,169,152 bytes.

It also fixes a bug where a CAR shard could be created with size greater than the shard size.

supersedes #764

As discussed in #764 and calculated in https://observablehq.com/@gozala/w3up-shard-size, this PR adjusts the upload-client to shard on a CAR size of <= 133,169,152 bytes.

It also fixes a bug where a CAR shard could be created with size greater than the shard size.

supersedes #764
await unixfsWriter.close()
try {
await fileBuilder.finalize(unixfsWriter)
await unixfsWriter.close()
Copy link
Member Author

Choose a reason for hiding this comment

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

Calling close on a writable stream that has errored causes this to throw an uncaught exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

☝️ This should probably be a code comment, also I don't think just logging an error is much better, browsers will log such errors and in node you can decide what to do. If we just log error things will appear to work but then break don't they ?

We should probably propagate error into returned readable somehow although I have to say I'm not sure how can we do that.

Any idea in what circumstances writable stream would error, it's not even exposed outside so if it errors perhaps it's problem in the UnixFS writer that can be fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed and refactored the test so we don't encounter it.

What was causing it was the tests that were triggering the ShardingStream to error because a block is too big and it caused the CAR to exceed the shard size.

Copy link
Contributor

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

Provided some optional feedback here and there, thanks for making it happen!

I'm only worried about console.error which I'm not sure is better than throwing, that said I think we should land this and deal with that in the followup.

packages/upload-client/src/car.js Outdated Show resolved Hide resolved
packages/upload-client/src/sharding.js Outdated Show resolved Hide resolved
packages/upload-client/src/sharding.js Outdated Show resolved Hide resolved
packages/upload-client/src/sharding.js Outdated Show resolved Hide resolved
packages/upload-client/src/sharding.js Outdated Show resolved Hide resolved
packages/upload-client/src/sharding.js Outdated Show resolved Hide resolved
await unixfsWriter.close()
try {
await fileBuilder.finalize(unixfsWriter)
await unixfsWriter.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

☝️ This should probably be a code comment, also I don't think just logging an error is much better, browsers will log such errors and in node you can decide what to do. If we just log error things will appear to work but then break don't they ?

We should probably propagate error into returned readable somehow although I have to say I'm not sure how can we do that.

Any idea in what circumstances writable stream would error, it's not even exposed outside so if it errors perhaps it's problem in the UnixFS writer that can be fixed.

@alanshaw alanshaw merged commit 944182a into main Sep 7, 2023
14 checks passed
@alanshaw alanshaw deleted the feat/adjust-shard-size branch September 7, 2023 09:18
alanshaw pushed a commit that referenced this pull request Sep 7, 2023
🤖 I have created a release *beep* *boop*
---


##
[9.2.0](upload-client-v9.1.2...upload-client-v9.2.0)
(2023-09-07)


### Features

* adjust shard size
([#908](#908))
([944182a](944182a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants