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
Remove the web-streams-polyfill #665
Comments
Adding new type RequestInformation.content: contentType; |
Thanks, that's really valuable feedback. I had added this polyfill out of old habbit, but data shows we can safely remove it. Would you mind taking this on please? |
Also, the polyfill is present in abstrations, serialization/json, http/fetch. |
resuming the conversation here since we've made a few "discoveries" in the PR linked above.
it seems we went from that to a union type between the two types (node & browser) first. Which caused type leaking issues across environments it then seems we went to a empty interface instead to avoid the leakage. Does this resume the progression well on this issue? Am I missing anything here? Now the down side of using an empty interface is that now we have to maintain code to understand which runtime are we in, and deal with particularities of imports, instantiation, and potential API surface differences. Which adds a lot of complexity to our code. Hence my suggestion: let's keep web streams, but use is as a ponyfill, not a polyfill, so globals are not impacted. The main draw back here is that we might have compatibility issues with the fetch library we're targeting, but that can be patched in the request adapter, which limits the impact to a single class, instead of leaking runtime management code all over the place. Any issue with that approach I'm missing? |
The main drawback of using the
|
too bad the whatwg stream spec implementation is still at an experimental stage, it'd go a long way to solve our issues here. instead of driving things with an empty interface, could we:
What I want to avoid is:
|
Can you frame the discussion in terms of the kiota maintainers, client developer, and end user developers? This clarification would be really helpful to understand design considerations like this since I think the concerns shared by both of you fall under different aspects of this work. I'd like to understand what are the costs and benefits of this proposed change for each of the personas above. Then it would be easier to determine what course to make. For example, as I understand it (very basic and I'm confident that I'm missing nuance), @baywet is optimizing for kiota maintainers so that we don't have to manage code duplication and having marker interfaces. @nikithauc is optimizing for client developer and end user developer as they won't need to handle the conversion between the node stream API and web stream API. Can you both please frame the costs and benefits in terms of these personas? There are burden tradeoffs for the many options here and we should be clear who will benefit and be burdened with each option. edited |
@nikithauc Please don't create a type called ContentType that is type stream. That is very confusing. ContentType is the name of a header that is a string. |
@baywet This https://caniuse.com/?search=ReadableStream claims 95% support for ReadableStream. @nikithauc I agree that 7MB for a polyfill for streams is heavy. Ridiculously so, in my opinion. I agree that empty interfaces are problematic. Especially for JS newbs like me. I like the idea of derived types per platform. |
I am currently investigating #841. I am getting a bad request because of the
This was an alternative considered. Not implementing here. But thank you for bringing up the naming confusion point! |
To extend on the conversation:
This would mean we have an easy and isomorphic solution for streams. We'd be left with fetch, for which we could either take a dependency on an isomorphic library (should they chose to upgrade), or limit the impact of switch/shipping variants to http client/fetch request adapter in the http lib. |
Removed the polyfill in #991. |
Concerns:
Error:
node-fetch
expects a NodeJS.Readable stream as the Request and Response content. https://github.com/node-fetch/node-fetch#bodybody. Example of a conflict error:cross-fetch
exports thenode-fetch
implementation offetch
when the environment is node (or a user using node-fetch library explicitly)Body
expects aNodeJS.Readable
class. This will clash as theweb-streams-polyfill
relies on the Web Stream API which is different from node.Solution:
Stream
implementation. That is:Browser : https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
NodeJS : https://nodejs.org/api/stream.html#stream_readable_streams
This is a cleaner approach and working with native implementations gives more flexibility for development.
For example, a node user will more commonly work with the node
stream
classes and not need the web polyfills. Relying on the native implementation saving user efforts to convert the from web to node definitions.User's can use polyfill on need basis. We avoid bugs caused by the polyfill. Also, if the polyfill is outdated then native implementation updates are not in sync.
https://www.w3.org/2001/tag/doc/polyfills/#use-native-implementations-when-available
AB#11303
The text was updated successfully, but these errors were encountered: