-
-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use request to normalize options #180
Use request to normalize options #180
Conversation
d26b9cd
to
48379b8
Compare
Maybe I just need some sleep and am missing something obvious, but it's not clear to me why that timeout test is failing. I did not intentionally change any timeout or retry behavior. Any thoughts @szmarczak? |
timeout | ||
}; | ||
this._fetchOptions = { | ||
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208 |
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.
I tested Chrome, Firefox, Safari, and Edge 18, and all of them default to same-origin
now. Not sure about mobile browsers, though. Should we remove this?
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.
Nah, not worth the risk. It's only a few bytes anyway.
48379b8
to
aac5c61
Compare
I kinda want to change the signature of hooks. Prior to this PR, we had:
This PR changes
|
3947db2
to
8cc6381
Compare
8cc6381
to
dd90790
Compare
Ready for review. Could use help on that one failing test. |
For now, I've worked around the timeout test issue by changing it to validate synchronously. I would argue that:
|
Promise-returning methods should always reject: https://twitter.com/jaffathecake/status/638659818996269056?s=21 |
024dfd7
to
aea8084
Compare
Alright, I made it a rejection. It's still validated in the constructor to work around the broken test that failed for reasons I don't understand. |
aea8084
to
af65656
Compare
af65656
to
42b1de4
Compare
It was a real pain to make it reject asynchronously before the request, because the rejected promise didn't have the I wholeheartedly disagree with this design pattern of rejecting user mistakes asynchronously. But I aim to please, so I made it work. The tests are passing. Please review. At this point, the main thing I'm wondering is what options the hooks should receive. I'm thinking either: The benefit of As for |
154902c
to
57763b7
Compare
57763b7
to
e0a0376
Compare
Anything else needed here? In addition to the issues that this PR already addresses, I also have fixes for #167, #182, and #187, which I want to implement on top of these changes. I could easily include those in this PR (most of them actually remove lines of code), however I don't want to do too many unrelated things and make it harder to review. If we can merge this soon, I will get to those quickly. It would be preferable to hold off on a release (even though everything here is working as-is). I realized that hooks really should be receiving all options for both Ky and fetch mixed together, so that the hooks themselves can call Ky and "inherit" the Ky options. I'd like to address that at the same time as #167, which as mentioned previously, should probably be done in a separate PR. |
This is great. Nice work 👌 And sorry for the delay. I reviewed this a week ago and was going to merge and then got distracted and forgot about it... |
@sindresorhus is codecov broken? I just noticed that the status check for this PR says "No report found to compare against" and clicking on the details also doesn't bring up anything useful. Maybe it needs to be re-authorized? |
Ah yeah. It was not enabled on the GitHub side. Done now. |
Closes #166
Closes #139
This PR:
Request
instance is now used as the source of truth instead ofinput
. This replaces some of the bespoke logic that we've had for processing options. It also makes life easier for people using thehooks
option, because they will receive a normalizedrequest
, whose behavior is more obvious and is well-specified by web standards. We can discuss whether the raw input should be available as well.fetch
options internally, so there's a clear distinction and it's easy to pass around one or the other, or both.beforeRequest
hooks to return aRequest
instance to replace the existing request.