-
Notifications
You must be signed in to change notification settings - Fork 265
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
chore: Use fetch as default for browsers instead of reqwest #199
Conversation
@@ -33,8 +33,8 @@ function fetchRequest(method, url, args) { | |||
} | |||
return result; | |||
}; | |||
if (response.headers.get('Accept') && | |||
response.headers.get('Accept').toLowerCase().indexOf('application/json') >= 0) { | |||
if (response.headers.get('Content-Type') && |
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.
Corrected, should be Content-Type
in response.
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.
🤦♂️
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.
Double checking - now that we're using cross-fetch in our tests, are we able to catch this error?
Also, did notice that we're not mocking out the response.text()
function here - do we need to? In general, when will be have a response that's not application/json?
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.
Yes, now we are able to catch that!
fyi, response.text()
was working properly anyway for our flow, since we always do a JSON.parse
in http https://github.com/okta/okta-auth-js/blob/master/lib/http.js#L60, this is why I haven't notice that during manual testing.
For what I have seen all our response should be application/json, so maybe should I remove the if/else?
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.
Seems reasonable if we're catching it downstream. Would also be curious why we have that code to handle it in the first place - my hunch is that at some point we'd occasionally return an error that was not a json response. This might be fixed now though.
ad380bf
to
7f2df4f
Compare
7f2df4f
to
47be450
Compare
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.
curious how did the cross browser testing go?
some thoughts on refactor dirctory
|
@haishengwu-okta good points! But as for /jquery, planning on doing those later when we bump major version, since they would be breaking changes (except for the third bullet). |
@@ -33,8 +33,8 @@ function fetchRequest(method, url, args) { | |||
} | |||
return result; | |||
}; | |||
if (response.headers.get('Accept') && | |||
response.headers.get('Accept').toLowerCase().indexOf('application/json') >= 0) { | |||
if (response.headers.get('Content-Type') && |
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.
Double checking - now that we're using cross-fetch in our tests, are we able to catch this error?
Also, did notice that we're not mocking out the response.text()
function here - do we need to? In general, when will be have a response that's not application/json?
@haishengwu-okta Sorry for the wait, took long time to get the cross browser testing completed. But, good news! They all passed! |
cf1a8ec
to
b5e3dc0
Compare
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.
Looks great 🚀
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.
looks good to me. would be great if we can get tested at embedded browser and 🚢
@haishengwu-okta fyi, @vijetmahabaleshwar-okta just completed the embedded browser testing (thank you Vijet!), everything good 👍 |
Completed sanity testing your branch. Everything looks good. |
Description
okta-auth-js
usereqwest
by default as a http request library, this change make it usecross-fetch
instead.jquery
as a request library, converted it to usecross-fetch
instead.Note: Will now try with alpha versions if it works in okta-signing-widget + okta-core before merging.
Note2: Haven't removed the possibility to use jquery as a request library (and the jquery dependency) because it would be a breaking change. But we can easily remove it next time we bump major version.
Reviewers
@haishengwu-okta @jmelberg-okta @rchild-okta