Catch exception and report it when making a network request with invalid URL on Android#18103
Catch exception and report it when making a network request with invalid URL on Android#18103jcurtis wants to merge 1 commit into
Conversation
…lid URL on Android
Currently if you invoke `fetch()` with an invalid URL ("aaa" for
example) you cannot catch the error in javascript since it's not
reported. Instead the entire app crashes.
Fixes react#7436 and react#18087
Hopefully.
|
Maybe more test cases could be added such as:
which I think currently throw this uncatchable error. |
|
@laurent22 I'm not sure that's necessary. We're just testing that the error gets reported and not the actual URL builder itself. If it's any invalid URL it should get reported. |
|
We also want to add check for valid URL on the JS side to synchronously report the error, but this is a good start. @facebook-github-bot shipit |
|
Something went wrong executing that command, @hramos could you take a look? |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@satya164 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This sync includes the following changes: - **[b5c6dd2](react/react@b5c6dd2de )**: Don't use Spread in DevTools Injection (#18277) //<Sebastian Markbåge>// - **[a463fef](react/react@a463fef31 )**: Revert "[React Native] Add getInspectorDataForViewAtPoint (#18233)" //<Sebastian Markbage>// - **[dc7eeda](react/react@dc7eedae3 )**: Encode server rendered host components as array tuples (#18273) //<Sebastian Markbåge>// - **[bf35108](react/react@bf351089a )**: [React Native] Add getInspectorDataForViewAtPoint (#18233) //<Ricky>// - **[99d7371](react/react@99d737186 )**: [Flight] Split Streaming from Relay Implemenation (#18260) //<Sebastian Markbåge>// - **[160505b](react/react@160505b0c )**: ReactDOM.useEvent: Add more scaffolding for useEvent hook (#18271) //<Dominic Gannaway>// - **[526c12f](react/react@526c12f49 )**: Enable enableProfilerCommitHooks flag for FB (#18230) //<Brian Vaughn>// - **[2953425](react/react@29534252a )**: ReactDOM.useEvent add flag and entry point (#18267) //<Dominic Gannaway>// - **[704c8b0](react/react@704c8b011 )**: Fix Flow type for AnyNativeEvent (#18266) //<Dominic Gannaway>// - **[bdc5cc4](react/react@bdc5cc463 )**: Add Relay Flight Build (#18242) //<Sebastian Markbåge>// - **[7a1691c](react/react@7a1691cdf )**: Refactor Host Config Infra (getting rid of .inline*.js) (#18240) //<Sebastian Markbåge>// - **[238b57f](react/react@238b57f0f )**: [Blocks] Make it possible to have lazy initialized and lazy loaded Blocks (#18220) //<Sebastian Markbåge>// - **[235a6c4](react/react@235a6c4af )**: Bugfix: Dropped effects in Legacy Mode Suspense (#18238) //<Andrew Clark>// - **[562cf01](react/react@562cf013d )**: Add a flag to disable module pattern components (#18133) //<Dan Abramov>// - **[115cd12](react/react@115cd12d9 )**: Add test run that uses www feature flags (#18234) //<Andrew Clark>// - **[4027f2a](react/react@4027f2a3b )**: Break up require/import statements in strings (#18222) //<Christoph Nakazawa>// - **[024a764](react/react@024a76431 )**: Implemented Profiler onCommit() and onPostCommit() hooks (#17910) //<Brian Vaughn>// - **[d35f8a5](react/react@d35f8a581 )**: feat: honor displayName of context types (#18224) //<Brian Vaughn>// - **[3ee812e](react/react@3ee812e6b )**: Revert "feat: honor displayName of context types (#18035)" (#18223) //<Dominic Gannaway>// - **[6a0efdd](react/react@6a0efddd8 )**: Modern Event System: export internal FB flag for testing (#18221) //<Dominic Gannaway>// - **[fa03206](react/react@fa03206ee )**: Remove _ctor field from Lazy components (#18217) //<Sebastian Markbåge>// - **[2fe0fbb](react/react@2fe0fbb05 )**: Use accumulateTwoPhaseDispatchesSingle directly (#18203) //<Dominic Gannaway>// - **[503fd82](react/react@503fd82b4 )**: Modern Event System: Add support for internal FB Primer (#18210) //<Dominic Gannaway>// - **[45c172d](react/react@45c172d94 )**: feat: honor displayName of context types (#18035) //<Brian Vaughn>// - **[ec652f4](react/react@ec652f4da )**: Bugfix: Expired partial tree infinite loops (#17949) //<Andrew Clark>// - **[d2158d6](react/react@d2158d6cc )**: Fix flow types (#18204) //<Brian Vaughn>// - **[7e83af1](react/react@7e83af17c )**: Put React.jsx and React.jsxDEV behind experimental build (#18023) //<Luna Ruan>// - **[8cb2fb2](react/react@8cb2fb21e )**: Refine isFiberSuspenseAndTimedOut (#18184) //<Dominic Gannaway>// - **[62861bb](react/react@62861bbcc )**: More event system cleanup and scaffolding (#18179) //<Dominic Gannaway>// - **[8ccfce4](react/react@8ccfce460 )**: Only use Rollup's CommonJS plugin for "react-art" (#18186) //<Sebastian Markbåge>// - **[c26506a](react/react@c26506a7d )**: Update react-shallow-renderer from 16.12.0 to 16.13.0 (#18185) //<Minh Nguyen>// - **[26aa198](react/react@26aa1987c )**: [Native] Enable and remove targetAsInstance feature flag. (#18182) //<Eli White>// - **[4469700](react/react@4469700bb )**: Change ReactVersion from CJS to ES module (#18181) //<Sebastian Markbåge>// - **[58eedbb](react/react@58eedbb02 )**: Check in a forked version of object-assign only for UMD builds (#18180) //<Sebastian Markbåge>// - **[053347e](react/react@053347e6b )**: react-test-renderer: improve findByType() error message (#17439) //<Henry Q. Dineen>// - **[4ee592e](react/react@4ee592e95 )**: Add an early invariant to debug a mystery crash (#18159) //<Dan Abramov>// - **[7ea4e41](react/react@7ea4e4111 )**: Fix typo in warning text (#18103) //<Sophie Alpert>// - **[79a2512](react/react@79a25125b )**: feat: add recommended config eslint rule (#14762) //<Simen Bekkhus>// - **[ae60caa](react/react@ae60caacf )**: [Fabric] Fix targetAsInstance dispatchEvent "cannot read property of null" (#18156) //<Joshua Gross>// - **[d72700f](react/react@d72700ff5 )**: Remove runtime dependency on prop-types (#18127) //<Dan Abramov>// - **[549e418](react/react@549e41883 )**: Move remaining things to named exports (#18165) //<Sebastian Markbåge>// - **[739f20b](react/react@739f20bed )**: Remove Node shallow builds (#18157) //<Sebastian Markbåge>// - **[3e809bf](react/react@3e809bf5d )**: Convert React Native builds to named exports (#18136) //<Sebastian Markbåge>// - **[869dbda](react/react@869dbda72 )**: Don't build shallow renderer for FB (#18153) //<Dan Abramov>// - **[293878e](react/react@293878e07 )**: Replace ReactShallowRenderer with a dependency (#18144) //<Minh Nguyen>// - **[b4e3148](react/react@b4e314891 )**: Remove unused flag (#18132) //<Dan Abramov>// - **[849e832](react/react@849e8328b )**: Remove unnecessary warnings (#18135) //<Dan Abramov>// - **[f9c0a45](react/react@f9c0a4544 )**: Convert the rest of react-dom and react-test-renderer to Named Exports (#18145) //<Sebastian Markbåge>// - **[c1c5499](react/react@c1c5499cc )**: update version numbers for 16.13 (#18143) //<Sunil Pai>// - **[e1c7e65](react/react@e1c7e651f )**: Update ReactDebugHooks to handle composite hooks (#18130) //<Brian Vaughn>// - **[d28bd29](react/react@d28bd2994 )**: remove OSS testing builds (#18138) //<Sunil Pai>// - **[8e13e77](react/react@8e13e770e )**: Remove /testing entry point from 'react' package (#18137) //<Sebastian Markbåge>// - **[60016c4](react/react@60016c448 )**: Export React as Named Exports instead of CommonJS (#18106) //<Sebastian Markbåge>// - **[8d7535e](react/react@8d7535e54 )**: Add nolint to FB bundle headers (#18126) //<Dominic Gannaway>// - **[bf13d3e](react/react@bf13d3e3c )**: [eslint-plugin-react-hooks] Fix cyclic caching for loops containing a… (#16853) //<Moji Izadmehr>// - **[501a788](react/react@501a78881 )**: runAllPassiveEffectDestroysBeforeCreates's feature flag description typo fixed (#18115) //<adasq>// - **[0934879](react/react@09348798a )**: Codemod to import * as React from "react"; (#18102) //<Sebastian Markbåge>// - **[78e8160](react/react@78e816032 )**: Don't warn about unmounted updates if pending passive unmount (#18096) //<Brian Vaughn>// - **[2c4221c](react/react@2c4221ce8 )**: Change string refs in function component message (#18031) //<Sebastian Markbåge>// - **[65bbda7](react/react@65bbda7f1 )**: Rename Chunks API to Blocks (#18086) //<Sebastian Markbåge>// - **[8b596e0](react/react@8b596e00a )**: Remove unused arguments in the reconciler (#18092) //<Dan Abramov>// - **[5de5b61](react/react@5de5b6150 )**: Bugfix: `memo` drops lower pri updates on bail out (#18091) //<Andrew Clark>// - **[abfbae0](react/react@abfbae02a )**: Update Rollup version to 1.19.4 and fix breaking changes (#15037) //<Kunuk Nykjær>// - **[b789060](react/react@b789060dc )**: Feature Flag for React.jsx` "spreading a key to jsx" warning (#18074) //<Sunil Pai>// - **[3f85d53](react/react@3f85d53ca )**: Further pre-requisite changes to plugin event system (#18083) //<Dominic Gannaway>// - **[ea6ed3d](react/react@ea6ed3dbb )**: Warn for update on different component in render (#17099) //<Andrew Clark>// - **[085d021](react/react@085d02133 )**: [Native] Migrate focus/blur to call TextInputState with the host component (#18068) //<Eli White>// - **[1000f61](react/react@1000f6135 )**: Add container to event listener signature (#18075) //<Dominic Gannaway>// - **[a12dd52](react/react@a12dd52a4 )**: Don't build some packages for WWW (#18078) //<Dan Abramov>// - **[2512c30](react/react@2512c309e )**: Remove Flare bundles from build (#18077) //<Dominic Gannaway>// - **[4912ba3](react/react@4912ba31e )**: Add modern event system flag + rename legacy plugin module (#18073) //<Dominic Gannaway>// - **[4d9f850](react/react@4d9f85006 )**: Re-throw errors thrown by the renderer at the root in the complete phase (#18029) //<Andrew Clark>// - **[14afeb1](react/react@14afeb103 )**: Added missing feature flag //<Brian Vaughn>// - **[691096c](react/react@691096c95 )**: Split recent passive effects changes into 2 flags (#18030) //<Brian Vaughn>// - **[56d8a73](react/react@56d8a73af )**: [www] Disable Scheduler `timeout` w/ dynamic flag (#18069) //<Andrew Clark>// - **[d533229](react/react@d533229fb )**: Fix Prettier //<Dan Abramov>// - **[56a8c35](react/react@56a8c3532 )**: [email protected] //<Dan Abramov>// - **[93a229b](react/react@93a229bab )**: Update eslint rule exhaustive deps to use new suggestions feature (#17385) //<Will Douglas>// - **[9def56e](react/react@9def56ec0 )**: Refactor DOM plugin system to single module (#18025) //<Dominic Gannaway>// - **[2d6be75](react/react@2d6be757d )**: [Native] Delete NativeComponent and NativeMethodsMixin (#18036) //<Eli White>// - **[d4f2b03](react/react@d4f2b0379 )**: Add Auto Import to Babel Plugin (#16626) //<Luna Ruan>// - **[8777b44](react/react@8777b44e9 )**: Add Modern WWW build (#18028) //<Dan Abramov>// - **[a607ea4](react/react@a607ea4c4 )**: Remove getIsHydrating (#18019) //<Dan Abramov>// - **[f727803](react/react@f7278034d )**: Flush all passive destroy fns before calling create fns (#17947) //<Brian Vaughn>// - **[529e58a](react/react@529e58ab0 )**: Remove legacy www config from Rollup build (#18016) //<Dominic Gannaway>// - **[42918f4](react/react@42918f40a )**: Change build from babylon to babel (#18015) //<Dominic Gannaway>// - **[df5fadd](react/react@df5faddcc )**: Refactor commitPlacement to recursively insert nodes (#17996) //<Dominic Gannaway>// - **[517de74](react/react@517de74b0 )**: Tweak comment wording (#18007) //<Dan Abramov>// - **[b63cb6f](react/react@b63cb6f6c )**: Update ReactFiberExpirationTime.js (#17825) //<haseeb>// - **[89c6042](react/react@89c6042df )**: fix: typo in test (#18005) //<Jesse Katsumata>// - **[4f71f25](react/react@4f71f25a3 )**: Re-enable shorthand CSS property collision warning (#18002) //<Sophie Alpert>// - **[c55c34e](react/react@c55c34e46 )**: Move React Map child check to behind flags or __DEV__ (#17995) //<Dominic Gannaway>// - **[3f814e7](react/react@3f814e758 )**: Fix Flow type for React Native (#17992) //<Dan Abramov>// - **[256d78d](react/react@256d78d11 )**: Add feature flag for removing children Map support (#17990) //<Dominic Gannaway>// - **[9dba218](react/react@9dba218d9 )**: [Mock Scheduler] Mimic browser's advanceTime (#17967) //<Andrew Clark>// - **[d6e08fe](react/react@d6e08fe0a )**: Remove Suspense priority warning (#17971) //<Dan Abramov>// - **[812277d](react/react@812277dab )**: Fix onMouseEnter is fired on disabled buttons (#17675) //<Alfredo Granja>// - **[3e9251d](react/react@3e9251d60 )**: make testing builds for React/ReactDOM (#17915) //<Sunil Pai>// - **[ace9e81](react/react@ace9e8134 )**: Simplify Continuous Hydration Targets (#17952) //<Sebastian Markbåge>// - **[7df32c4](react/react@7df32c4c8 )**: Flush `useEffect` clean up functions in the passive effects phase (#17925) //<Brian Vaughn>// - **[434770c](react/react@434770c3b )**: Add beforeRemoveInstance method to ReactNoop (#17959) //<Dominic Gannaway>// - **[6ae2c33](react/react@6ae2c33a7 )**: StrictMode should call sCU twice in DEV (#17942) //<Brian Vaughn>// - **[9dbe1c5](react/react@9dbe1c54d )**: Revert "Bugfix: Expiring a partially completed tree (#17926)" (#17941) //<Andrew Clark>// - **[b2382a7](react/react@b2382a715 )**: Add ReactDOM.unstable_renderSubtreeIntoContainer warning flag (#17936) //<Dominic Gannaway>// - **[01974a8](react/react@01974a867 )**: Bugfix: Expiring a partially completed tree (#17926) //<Andrew Clark>// Changelog: [General][Changed] - React Native sync for revisions 241c446...b5c6dd2 Reviewed By: gaearon Differential Revision: D20347361 fbshipit-source-id: e9e6282474ab6471585e8e7fb6ea8518aa48390d
Currently if you invoke
fetch()with an invalid URL ("aaa" forexample) you cannot catch the error in javascript since it's not
reported. Instead the entire app crashes.
Fixes #7436 and #18087
Hopefully.
Motivation
Fix using fetch on Android with user generated input.
Test Plan
Added relevant unit test
./scripts/run-android-local-unit-tests.shall passRelease Notes
[ANDROID] [BUGFIX] [fetch] - Allow "unexpected url" exception to be caught on Android when using fetch