-
- Notifications
You must be signed in to change notification settings - Fork 239
use isomorphic-fetch simplify http resolver #202
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
Conversation
| Conceptually this seems like a good idea, but a few things: Firstly, is there any documentation required to fully solve #107, does the user need to change anything or is it just magic? Secondly. another attempt was made to fix #107 by using request in #108, and that was closed as it doesn't work in the browser. fetch() does work in the browser ofc, but we might need to do a little more work to make sure node-fetch is only loaded in node and normal fetch is available in the browser. @P0lip I'd appreciate your input here on the second thing, because this will effect @stoplightio stuff, probably for the better. |
support via see https://github.com/node-fetch/node-fetch/blob/2.x/package.json#L6 |
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.
Thanks for the PR!
I'm very supportive when it comes to getting rid of http and https. It's a step in good direction since this makes the integration of json-schema-ref-parser in browser environment much easier.
There are a few comments left to address, however.
Let me know if anything needs further clarification. Happy to help getting this PR over the finish line.
lib/resolvers/http.js Outdated
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.
Unfortunately, Request does not support timeout.
You need to use AbortController.
There is a neat usage example included in the link above.
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.
see https://github.com/node-fetch/node-fetch#request-cancellation-with-abortsignal
i think, remove timeout option may be better.
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.
if so, need to add extra library, https://npm.im/abort-controller (over 2 year, no any update)
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.
Let's add the library. The fact the last release took place 2 years is nothing wrong. The spec has simply not changed since then, so there was no need to introduce any change.
I had a chance to utilize that library in the past and I can say it's solid.
| I think removing timeouts and redirect logic is a little nuclear here, as there are alternative approaches. To get timeouts working with abort controller: https://dmitripavlutin.com/timeout-fetch-request/ There's some stuff on google about follow redirects being built in https://stackoverflow.com/questions/39735496/redirect-after-a-fetch-post-call#39739894 but im not sure if thats going to work for this specific implementation. Anyhow, if we remove these that's probably a major release, and it's not a great sales pitch to just say there's less functionality now. |
| Btw I appreciate your work on this! Sorry if that doesn't come across, I write a little too quickly sometimes, never mean to sound rude! 😅 |
| i planning use typescript design a new library. |
| @septs I don't understand. You had almost finished this feature and instead something something now you're doing a new one in TypeScript? There's already a TypeScript rewrite of this library that's coming along quite nicely, and it does a lot more than just switch to TS. There's years of domain knowledge built up in this codebase and that one. Would you like to work together instead of duplicating efforts? |
fix #107