-
Notifications
You must be signed in to change notification settings - Fork 22
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
Conversation
…orting it in bundled setups breaks
// the fetch implementation didn't support onUploadProgress | ||
const carBlob = new Blob([car]) | ||
options.onUploadProgress({ | ||
total: carBlob.size, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
/** @type {(url: string, init?: import('./types.js').FetchOptions) => Promise<Response>} */ ( | ||
fetch | ||
) | ||
options.fetchWithUploadProgress || options.fetch || globalThis.fetch |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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.
🤖 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>
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