-
Notifications
You must be signed in to change notification settings - Fork 765
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: use native impit
streaming
#2833
Conversation
The initial implementation shows slight discrepancies in the types exported from the impit package, requiring awkward casts on this side. Those problems should be fixed in Edit: regular |
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.
Love it! Resolve my comments at will and feel free to merge.
private getStreamWithProgress( | ||
response: ImpitResponse, | ||
): [Readable, () => { percent: number; transferred: number; total: number }] { | ||
const responseStream = Readable.fromWeb(response.body as ReadableStream<any>); |
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.
Is the cast necessary? ImpitResponse['body']
looks like it's typed pretty well.
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.
yup, unfortunately, Readable.fromWeb
accepts ReadableStream
from node:stream/web
, but impit.fetch
(and, more importantly, Node's native fetch
) return ReadableStream
that gets resolved with TS's lib.dom.d.ts
type declarations. There is a slight discrepancy somewhere deep between those two types:
There may be a better solution somewhere, but given the (IMO small) size of this issue, a cast solves this just fine.
Bumps the
impit
dependency and required Node version for the@crawlee/impit-client
package. Makes use of the new nativeReadableStream
interface.Related to #2756