-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix: Error thrown when fetch argument is not a string or a Request object. #1069
Conversation
src/raven.js
Outdated
var method = 'GET'; | ||
var url; | ||
|
||
if (typeof fetchInput === 'string') { | ||
url = fetchInput; | ||
} else { | ||
} else if ( | ||
typeof 'Request' !== undefined && |
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.
This will always return true
, as typeof 'Request'
is always string
.
Use 'Request' in _window
to verify that Request
is available.
src/raven.js
Outdated
url = fetchInput.url; | ||
if (fetchInput.method) { | ||
method = fetchInput.method; | ||
} | ||
} else { | ||
url = String(fetchInput); |
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.
Can you use url = '' + url
instead? We use this syntax throughout the codebase.
Hey! |
Hello, @kamilogorek , I've made the requested changes and updated the pull request. Thank you! |
Thanks! |
@vierno so, I agree Raven shouldn't choke when it gets an argument like this, but I'm curious if there's any actual defined behavior for |
@benvinegar , the browser uses the string representation of the argument as the url. So |
Unfortunately this test is failing on IE10/11/Safari10, but I'll try to fix it. Unfortunately, our setup at the moment doesn't allow to run SauceLabs tests for non-organization members. We're working on fixing this setup as well. |
@vierno – Ah, thanks for the clarification. |
Hello,
When using fetch and the first parameter of fetch is
undefined
, raven is throwing an error:This fix covers the cases where the first arg of fetch is neither a string or a Request object.