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: dont use ipfs-utils fetch with upload progress by default #1240

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

gobengo
Copy link
Contributor

@gobengo gobengo commented Dec 13, 2023

because importing it in bundled setups breaks, e.g.

I tested this change locally and confirmed that once it's made, upload-client can be relied on by a nextjs project and build successfully

@gobengo gobengo marked this pull request as ready for review December 13, 2023 18:18
@gobengo gobengo changed the title dont use ipfs-utils fetch with upload progress by default feat: dont use ipfs-utils fetch with upload progress by default Dec 13, 2023
// the fetch implementation didn't support onUploadProgress
const carBlob = new Blob([car])
options.onUploadProgress({
total: carBlob.size,
Copy link
Contributor

Choose a reason for hiding this comment

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

are total and loaded here the same because this will be the only progress event sent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep! the only progress even for this car file, and all we know here is the fetch succeeded so it's 100% progress all at once

@gobengo gobengo merged commit 86aedbc into main Dec 13, 2023
3 checks passed
@gobengo gobengo deleted the js-ipfs-utils-no branch December 13, 2023 19:23
/** @type {(url: string, init?: import('./types.js').FetchOptions) => Promise<Response>} */ (
fetch
)
options.fetchWithUploadProgress || options.fetch || globalThis.fetch
Copy link
Member

Choose a reason for hiding this comment

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

Needs globalThis.fetch.bind(globalThis)

Copy link
Member

Choose a reason for hiding this comment

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

Just call it customFetch and type it as required?

IpfsUtilsFetchOptions,
{
// `fetch` is a browser API and browsers don't have `Readable`
body: Exclude<IpfsUtilsFetchOptions['body'], import('node:stream').Readable>
Copy link
Member

Choose a reason for hiding this comment

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

What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it excludes Readable from the allowed body types that come from ipfs-utils because that's not what other fetches will expect

@@ -0,0 +1,8 @@
import ipfsUtilsFetch from 'ipfs-utils/src/http/fetch.js'
Copy link
Member

Choose a reason for hiding this comment

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

🙏 Pull out as a separate library that solves the issue or send a PR.

travis added a commit that referenced this pull request Jan 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[13.0.0](upload-client-v12.3.2...upload-client-v13.0.0)
(2023-12-14)


### ⚠ BREAKING CHANGES

* return allocated bytes in `store/add` receipt
([#1213](#1213))

### Features

* dont use ipfs-utils fetch with upload progress by default
([#1240](#1240))
([86aedbc](86aedbc))
* return allocated bytes in `store/add` receipt
([#1213](#1213))
([5d52e44](5d52e44))


### Fixes

* bind globalThis.fetch to globalThis
([#1242](#1242))
([ef59358](ef59358))
* point `main` at files included in the package
([#1241](#1241))
([c0b306d](c0b306d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Travis Vachon <travis.vachon@protocol.ai>
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