Skip to content
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

fetch does not throw error with a malformed URL #17843

Closed
ghost opened this issue Feb 2, 2018 · 2 comments
Closed

fetch does not throw error with a malformed URL #17843

ghost opened this issue Feb 2, 2018 · 2 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@ghost
Copy link

ghost commented Feb 2, 2018

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

(Write your answer here.)

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.1
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.52.0 => 0.52.0

Steps to Reproduce

(Write your steps here:)

  1. Make a fetch request to a malformed url like https://http:.malformedurl.com
  2. The error is not propagated to the promise resolvers

Expected Behavior

The error should be thrown in the Javascript so that it can be caught in the catch block

Actual Behavior

(Write what happened. Add screenshots!)

Reproducible Demo

test = async () => {
    try {
      await fetch('https://http:.malformedurl.com/.jsapi/info')
      console.log('Fetch successful')
    }
    catch(error) {
      console.error(error); // never goes here
    }
    
  }
  componentDidMount() {
    this.test();
  }
  

screenshot_1517611982

@gedeagas
Copy link
Contributor

gedeagas commented Feb 4, 2018

Hello, @suparng-medallia thank you for your bug report.

after reviewing your code I must conclude this is not a bug and the code run as it should have.

catch(error) { console.error(error); // never goes here }

This part of the code is executed hence the red screen. if you want the error to be "thrown in the Javascript" ( log the error on debugger ) you can do that easily by changing the console.error() to console.log().

If you want to read more about debugging in react-native I suggest that you read the docs here
https://facebook.github.io/react-native/docs/debugging.html#in-app-errors-and-warnings

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon. labels Feb 24, 2018
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 24, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Feb 24, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants