Граф коммитов

170 Коммитов

Автор SHA1 Сообщение Дата
Moti Zilberman 5789e67760 Reuse preprocessed exception message in redbox after symbolication
Summary: Reuse preprocessed exception message when sending the symbolicated update to the redbox, in case `preprocessException` has actually modified it.

Reviewed By: cpojer

Differential Revision: D17318008

fbshipit-source-id: 8b4c606c662140fb44c5305e2f3c7faa0b60f0ee
2019-09-12 03:55:41 -07:00
Alec Larson 4fc3e7ae71 fix: avoid calling Timing.deleteTimer for setImmediate and requestIdleCallback (#26113)
Summary:
Fix a simple error where `types[index]` was being accessed after it was cleared, instead of before.

## Changelog

[iOS] [Fixed] - never call deleteTimer for setImmediate and requestIdleCallback
Pull Request resolved: https://github.com/facebook/react-native/pull/26113

Test Plan: None

Differential Revision: D17314489

Pulled By: cpojer

fbshipit-source-id: 74715f0f7cc2d5cee3b97a67313c5e96e9d6c555
2019-09-11 06:04:41 -07:00
Dan Abramov f107d3b78c Fix Redbox on iOS
Summary:
Looks like we broke iOS redbox in D16812212. It stopped showing up because the feature detection stopped working, and we started calling noops. The fix is an explicit platform check.

Fixes #26260

Reviewed By: motiz88

Differential Revision: D17139310

fbshipit-source-id: 829eec23cbb49151ac250889c34ab28d36b05e6a
2019-08-30 18:10:35 -07:00
Brian Vaughn 92a3c9da0a React DevTools v4 integration
Summary:
This Diff is being posted for discussion purposes. It will not be ready to land until React DevTools v4 has been published to NPM.

Update React Native to be compatible with the [new version 4 React DevTools extension](https://github.com/bvaughn/react-devtools-experimental).

**Note that this is a breaking change**, as the version 3 and version 4 backends are **not compatible**. Once this update ships (in React Native) users will be required to update their version of the [`react-devtools` NPM package](https://www.npmjs.com/package/react-devtools). The same will be true for IDEs like Nuclide as well as other developer tools like Flipper and [React Native Debugger](https://github.com/jhen0409/react-native-debugger).

Related changes also included in this diff are:
* Pass an explicit whitelist of style props for the React Native style editor (to improve developer experience when adding new styles).
* Update `YellowBox` console patching to coordinate with DevTools own console patching.
  * Also improved formatting slightly by not calling `stringifySafe` for strings (since this adds visible quotation marks).

Regarding the console patching- component stacks will be appended by default when there's no DevTools frontend open. The frontend will provide an option to turn this behavior off though:

{F168852162}

React DevTools will detect if the new version is used with an older version of React Native, and offer inline upgrade instructions:

{F169306863}

**Note that the change to the `RCTEnableTurboModule` will not be included in this Diff**. I've just turned those off temporarily so I can use v8+Chrome for debugging.

Reviewed By: rickhanlonii

Differential Revision: D15973709

fbshipit-source-id: bb9d83fc829af4693e7a10a622acc95a411a48e4
2019-08-26 23:56:59 -07:00
Moti Zilberman db9fab4473 Add unstable_setExceptionDecorator
Summary: Adds a way for the app to add information to an exception report before it is sent to native. This API is not final.

Reviewed By: rubennorte

Differential Revision: D16984151

fbshipit-source-id: 8450356d608e05deaed437e2a35094cd16962027
2019-08-23 11:52:30 -07:00
Logan Daniels 92073d4a71 Clean-up $TEMPORARY$object in xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16931667

fbshipit-source-id: d87e5ed02bf7f95005cf0f36c3cd127026189058
2019-08-21 09:58:24 -07:00
Peter Argany 30c1196d7d Convert RCTImageLoader to TurboModules [4/N]
Summary:
This diff adds a JS spec for RCTImageLoader, and conforms to it in ObjC++. Since RCTImageLoader isn't called from JS, the js spec is empty. Since `/CoreModules/` is the only dir in OSS which supports TM, move the ObjC++ impl there.

The change in `NativeExceptionsManager.js` fixes a weird bug I was hitting in codegen, where the codegen cpp file wouldn't compile due to unused variable.

Reviewed By: JoshuaGross

Differential Revision: D16495674

fbshipit-source-id: 191897b87730a6b0b96022eedc6412551fae04a6
2019-08-15 11:33:37 -07:00
Logan Daniels 91f139b941 xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16657770

fbshipit-source-id: 4e260842c838a35317515044c54ccf55a083da33
2019-08-09 10:11:15 -07:00
Moti Zilberman 3eaf245540 Pop frames correctly in console.error handler
Reviewed By: cpojer

Differential Revision: D16648992

fbshipit-source-id: 4581e2cd6859f27bc384fc3ab328ab5b9414c704
2019-08-05 11:19:56 -07:00
Moti Zilberman 9f85f1e39c Type ErrorUtils (error-guard.js)
Summary:
* Adds Flow types to `error-guard.js` and propagates them via the `ErrorUtils` module.
* Fixes some call sites to account for the stricter (correct) types.

Differential Revision: D16619538

fbshipit-source-id: c006ff2736ec380763956c4b89702cf44dd4deb0
2019-08-02 09:38:46 -07:00
Moti Zilberman 6764385c80 Type StackFrame fields as nullable
Summary: `parseErrorStack` (which uses the `stacktrace-parser` package) can return null file names, line numbers and column numbers. This diff updates the associated types and adds explicit null checks in some call sites.

Reviewed By: rickhanlonii

Differential Revision: D16542176

fbshipit-source-id: b72c73c05b95df0bbcb5b5baa7bc2d42cff1e074
2019-07-31 09:08:06 -07:00
Moti Zilberman 2dadb9e2b0 Move React error message formatting into ExceptionsManager
Summary:
# Context

In https://github.com/facebook/react/pull/16141 we imported `ReactFiberErrorDialog` unchanged from React. That implementation was not idempotent: if passed the same error instance multiple times, it would amend its `message` property every time, eventually leading to bloat and low-signal logs.

The message bloat problem is most evident when rendering multiple `lazy()` components that expose the same Error reference to React (e.g. due to some cache that vends the same rejected Promise multiple times).

More broadly, there's a need for structured, machine-readable logging to replace stringly-typed interfaces in both the production and development use cases.

# This diff

* We leave the user-supplied `message` field intact and instead do all the formatting inside `ExceptionsManager`. To avoid needless complexity, this **doesn't** always have the exact same output as the old code (but it does come close). See tests for the specifics.
* The only mutation we do on React-captured error instances is setting the `componentStack` expando property. This replaces any previously-captured component stack rather than adding to it, and so doesn't create bloat.
* We also report the exception fields `componentStack`, unformatted `message` (as `originalMessage`) and `name` directly to `NativeExceptionsManager` for future use.

Reviewed By: cpojer

Differential Revision: D16331228

fbshipit-source-id: 7b0539c2c83c7dd4e56db8508afcf367931ac71d
2019-07-31 02:34:15 -07:00
Moti Zilberman 77125a1ac3 Use Metro support for auto-collapsing internal stack frames (#25839)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/25839

Changes `ExceptionsManager` to respect the `collapse` field in each symbolicated stack frame returned from Metro. This is ultimately driven by a Metro config option (which will have a default set in https://github.com/react-native-community/cli/pull/596).

This is part of a redesign of work done originally in https://github.com/facebook/react-native/pull/24662.

Reviewed By: cpojer

Differential Revision: D16500277

fbshipit-source-id: b0b035618cb000935a555796523637b5f0a688d3
2019-07-29 07:44:56 -07:00
Christoph Nakazawa 81ec2112a1 Use HMRClient to send console logs to Metro
Summary:
This change switches the sending of log messages to Metro from HTTP over to WebSocket. This is what I should have done from the beginning *however* I only spent very little time on this initially, didn't realize that it would be a popular feature *and* we didn't have a persistent WebSocket connection on the client before that was always on. Together with D16442656 we can finally make this happen!

This change:
* Changes the `fetch` call to `HMRClient.log`
* Removes the middleware and integrates logging with `HmrServer` directly in Metro.
* Simplifies the logging logic as WebSockets guarantee messages are processed in order.

This also fixes an issue makovkastar identified when using the `MessageQueue` spy: because we send messages back and forth over the bridge, using `console.log` within `MessageQueue`'s spy method will actually cause an infinite logging loop. This is the proper solution to that problem instead of hacking around it using custom headers.

Note: in a follow-up we will rename these modules to drop the `HMR` prefix. We have not come up with a better name yet and are open to ideas.

Reviewed By: sebmck

Differential Revision: D16458499

fbshipit-source-id: 4c06acece1fef5234015c877354fb730b155168c
2019-07-24 08:11:34 -07:00
Dan Abramov 8b5ed7abdd Fixing error on first mount should fall back to reload
Summary:
This updates `react-refresh` to 0.3.0 which brings a new feature: we can now detect if the root fails on _the initial mount_. In that case we currently can't recover with Fast Refresh because we don't know which element to retry mounting. (In the future, we can lift this limitation, but it would require more changes in React renderer.)

Before this diff, after you fix an error on initial mount, you would see a blank screen (because nothing managed to mount).

After this diff, after you fix an error on initial mount, you would fall back to a full reload.

This diff doesn't affect errors on updates. We can recover from those, just like before.

Reviewed By: cpojer

Differential Revision: D16440836

fbshipit-source-id: 4a414202a9eab894acd7baa0525c25ff003dd323
2019-07-23 16:19:15 -07:00
Moti Zilberman c5180f4bfb Test more of ExceptionsManager
Summary: Renames `ReactFiberErrorDialog-test` to `ExceptionsManager-test` and adds tests for `console.error` and exceptions not captured by React. Some of this functionality is covered by the RNTester integration tests, but this JS test suite is both more comprehensive and easier to iterate against.

Reviewed By: cpojer

Differential Revision: D16363166

fbshipit-source-id: 32a4b89bb50131fae86e3c03db7eacbbcf86966b
2019-07-19 03:34:40 -07:00
Moti Zilberman 5029195d22 Test ReactFiberErrorDialog in terms of NativeExceptionsManager
Summary:
https://github.com/facebook/react-native/pull/25671 added a shallow unit test for `ReactFiberErrorDialog`, mocking out the (JS) `ExceptionsManager` module. This rewrites that test in terms of `NativeExceptionsManager` instead, so the integration with `ExceptionsManager` is also tested.

Also adds tests for the behaviour of the `framesToPop` and `jsEngine` extended error fields, and for passing a frozen error object (seeing as we potentially mutate the error).

Reviewed By: rickhanlonii

Differential Revision: D16330341

fbshipit-source-id: 0b514d1c8f193a114748739ec31ddb4e06e4d2fd
2019-07-18 07:50:39 -07:00
Dan Abramov 93aab84699 Remove the escape hatch
Summary: I originally added `forceFullRefresh` as an escape hatch in case Fast Refresh is too unreliable. In practice we haven't seen any major issues with it. Since this option is already very obscure, I'm just removing it.

Reviewed By: shergin

Differential Revision: D16286632

fbshipit-source-id: c3dc44cffd459912e194e273acf868f3380c64cc
2019-07-17 06:29:25 -07:00
Dan Abramov e9640aeeb2 Downgrade symbolication warning to a log
Summary: These warnings are both noisy and unactionable to product developers when you disconnect a Metro server. You also see them *after* the redbox is closed anyway, so you kind of already know if symbolication didn't work. So I'm downgrading it to a simple log.

Reviewed By: motiz88

Differential Revision: D16285591

fbshipit-source-id: c0e4c9168f66f4573404aa336ab889e4e9da0c22
2019-07-17 06:29:25 -07:00
Moti Zilberman 3a825c0360 Introduce NativeExceptionsManager.reportException API
Summary:
@public

`reportException` is a new method on `NativeExceptionsManager` that is designed to allow more structured and flexible JS error reporting. `reportFatalException` and `reportSoftException` are now deprecated.

In addition to all the usual exception fields, `reportException` also accepts an `extraData` property which the JS exception handler can populate with arbitrary JSON-serialisable data (here: the raw stack trace, the current JS engine, and the number of frames popped off the call stack by the exception handler). The contents of `extraData` get attached as JSON to the `JavascriptException` instance (or just logged, in the case of `console.error`).

This change is backwards compatible in two senses:
1. We have a JS fallback that uses `reportFatalException` and `reportSoftException` if the new native method is unavailable.
2. We have a Java fallback that implements `reportFatalException` and `reportSoftException` in terms of `reportException`.

Naturally, both fallbacks mentioned above discard `extraData`.

NOTE: The current implementation is Android-only; for the time being, iOS will continue to use the JS fallback.

While we're in `ExceptionsManager.js`, this also changes `dismissRedbox()` to be optional (which it is, since it's Android-only); existing call sites already guard it with a null check so this requires no other changes.

Reviewed By: mmmulani

Differential Revision: D16133080

fbshipit-source-id: d0b209d58da40b736df63155bbea232e94ce635c
2019-07-16 09:38:03 -07:00
Moti Zilberman a9cab21010 Add ReactFiberErrorDialog from React + tests (#25671)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/25671

Moves the RN-specific `ReactFiberErrorDialog` implementation from React to RN for easier iteration. Also adds new unit tests.

This current change is additive, so we're compatible with the current React renderer which still uses `ExceptionsManager` and not the file added here. After the corresponding React update we can remove `ExceptionsManager` from the RN private interface entirely.

Reviewed By: cpojer

Differential Revision: D16278938

fbshipit-source-id: 0c2c0c3e65e524e079730ae3b0cc23e0c0bdc5fd
2019-07-16 03:21:07 -07:00
Dan Abramov abc663dd5a Add a shim for HMRClient in prod bundles
Summary:
Running a PROD JS bundle with a DEV binary used to redbox with Fast Refresh on. The error said "HMRClient is not a registered callable module".

This isn't a new issue: https://www.google.com/search?q=%22hmrclient%20is%20not%20a%20registered%22. However, now it happens every time because `setup()` is now called unconditionally in a DEV native build.

Because a combination of DEV binary + PROD JS is technically possible, I'm adding a tiny shim that will make it a no-op instead of crashing. It will also explain what's wrong if you *intentionally* try to turn on Fast Refresh.

Reviewed By: sahrens

Differential Revision: D16145378

fbshipit-source-id: 0b9c0a6f30c02ca7f4a0133048450bdde3576ad2
2019-07-07 13:25:10 -07:00
Christoph Nakazawa 5dade01ca6 Remove setupDevtools file
Summary: There is a `setUpDeveloperTools.js` and a `setupDevtools.js` files. While they do set up different devtools it is very confusing to have these two files. This diff inlines one in the other which should bring more clarity.

Reviewed By: gaearon

Differential Revision: D16121236

fbshipit-source-id: 45641c7af9639ede6dc237ac53b763cd804a05c2
2019-07-04 09:22:09 -07:00
Christoph Nakazawa 76e10c4e8b Improve console logging to Metro
Summary:
This adds a few more methods that are forwarded to Metro, most notably `console.group`, `console.groupCollapsed` and `console.groupEnd`. When using `console.group`, node.js's `console` implementation will use indentation for log messages. `console.groupCollapsed`, for now, will simply not print anything to the console. This removes all of the Relay information that was impossible to look at in Metro before.

In the future, I'd like to consider somehow including collapsed groups in the output with a way to interact and navigate through them but for now, if people would like to debug Relay queries, they should use whatever they have been using before Metro had logs.

Reviewed By: gaearon

Differential Revision: D16108266

fbshipit-source-id: 97337d93eed0b8cb464df78b59ade1fe340b7f6f
2019-07-04 07:44:28 -07:00
Dan Abramov 08baec61c2 Re-evaluate parent modules when refresh boundary updates are incompatible
Summary:
This is a revamp of how we decide whether to stop at a refresh boundary or to bubble to the next one.

We used to decide that at module initialization. However, that's both unnecessary overhead on start (for modules you don't plan to edit), and is actually insufficient.

In particular, even if a module only exports components (and thus is a Refresh Boundary), consecutive versions of that module might not be compatible.

For example, any of these changes should trigger reevaluation of parents:

- Adding or removing exports
- Renaming the exported component (which probably means you exported a different one, and we shouldn't preserve state)
- Converting from a class to a function, or back
- Wrapping something in a HOC

The new system handles these cases by comparing the Refresh "families" corresponding to exports, and bubbling the update up if some of them don't match up.

The tests have been rewritten from the webpack-inspired `module.hot` API (which we no longer use directly) to the Refresh API.

Reviewed By: rubennorte

Differential Revision: D16036044

fbshipit-source-id: 18018548d4aaa05877ae6fbaffe40c993c77cdf0
2019-06-27 14:13:12 -07:00
Dan Abramov ea817fd7f5 Don't symbolicate transform errors
Summary:
Metro symbolication can be expensive in large apps. However, there is no need to symbolicate _runtime stacks from compile errors_. Those are pretty much useless anyway.

This will reduce the workload on Metro workers, and the delays when iterating with Fast Refresh, as the server will be busy much less often.

So I'm special-casing them and not sending the symbolication request anymore.

Reviewed By: rickhanlonii

Differential Revision: D16030087

fbshipit-source-id: 41f83ac01780c0a60cca777014e4ed95c0f3d14b
2019-06-27 07:58:50 -07:00
Dan Abramov 08bfdfad67 Remove useless module.hot checks
Summary:
Since we always create `module.hot` objects, the `module.hot` checks were unnecessary. They give a false impression that we're checking for a Hot Reloading mode. However, they're just Flow refinements and always exist in DEV. I made that explicit by throwing early.

Similarly, I removed a `module.hot` check inside `setupReactRefresh`, as it is always truish in DEV.

Finally, I'm adding a new mechanism as an escape hatch. It lets you do:

```
if (__DEV__) {
  require.Refresh.forceFullRefresh = true;
}
```

in your entry point and opt into full refreshes on every edit. This sounds similar to "Reload-on-Save". That is because in the next diff, I plan to remove "Reload-on-Save" from user-visible options (but it'll stay for automated workflows).

So this workaround is intended for people who for one reason or another don't want to opt into Hot Reloading as an alternative. We'll need to talk to them and find out why.

Reviewed By: rickhanlonii

Differential Revision: D15958475

fbshipit-source-id: 674187ddf86a4e286dfae28f4182555a8b5d7396
2019-06-24 09:48:57 -07:00
Dan Abramov d7c8ace001 Replace React Transform HMR with React Refresh
Summary:
This removes React Transform HMR in favor of the new React Refresh implementation. It should only affect the "Enable Hot Reloading" mode. In further diffs I will remove "React Transform HMR" completely.

This is technically a breaking change for Metro so it'll need a version bump.

Reviewed By: rickhanlonii, rubennorte

Differential Revision: D15903585

fbshipit-source-id: 074380b00868cb31857f599a03799d3584c35d87
2019-06-21 06:04:18 -07:00
Dan Abramov 1284c5d1f2 Add react-refresh as a dependency
Summary:
This adds the Fresh Babel plugin and runtime to React Native dependencies. **They're not actually being used or enabled yet**. This is purely additive and just gets the deps setup out of the way for future diffs.

The `react-refresh` source of truth is in the React repo.

Reviewed By: cpojer

Differential Revision: D15828330

fbshipit-source-id: 67ec2dea8c896477ff8b434445f1730e388ea67a
2019-06-17 10:59:05 -07:00
Emily Janzer aeef7b511e Disable dev tools in bridgeless mode
Summary: Developer tools have a lot of dependencies on the bridge, so for now I'm just disabling them in bridgeless mode entirely by guarding everything in `setUpDeveloperTools` with the `RN$Bridgeless` flag. Also consolidating some of the stuff Dan added to `InitializeCore` for hot reloading in here.

Reviewed By: zackargyle

Differential Revision: D15797924

fbshipit-source-id: 360ea81a2844e49f7281eed259fc16a541148ac2
2019-06-13 08:51:47 -07:00
Emily Janzer 533932ada9 Don't set up JS timers in bridgeless RN
Summary: For bridgeless RN we're not going to use the JSTimers module + Timing native module for timers (e.g. setTimeout, setImmediate, etc.). Instead we're going to install global functions from cpp for each of these, so we can just skip setUpTimers entirely in this case.

Reviewed By: fkgozali

Differential Revision: D15790638

fbshipit-source-id: 1626fe90a27cb8d385cbb700ad932969f708f0cb
2019-06-12 16:18:36 -07:00
Emily Janzer 4e7155ee53 Add RN$Bridgeless flag, use it to conditionally skip bridge setup
Summary:
In bridgeless mode we don't want to set up the batched bridge, which is set up as part of InitializeCore. Instead of deleting InitializeCore completely, let's just skip this step if we're in bridgeless mode, which we'll detect using a global variable set on the runtime from cpp (`RN$Bridgeless`).

This way you still get an error if the bridge is somehow not set up properly when you're not in bridgeless mode (it won't fail silently).

Reviewed By: fkgozali

Differential Revision: D15721940

fbshipit-source-id: 73896e25874dd000f37d1abc9cf6be549ab3434f
2019-06-10 15:03:01 -07:00
Christoph Nakazawa 93b9ac74e5 Remove Map/Set from RN Open Source
Summary:
This is the same diff as D14786123 but with one of the buck targets fixed that only failed on continuous and didn't run during land time.

 This moves Map/Set to fb internal. We do not need them in open source any more but we still need this in some apps at FB that use an old version of JSC.

Reviewed By: rickhanlonii

Differential Revision: D15713305

fbshipit-source-id: caec43c76a6255b2af1693c13d8dea31d7d674f5
2019-06-07 06:39:28 -07:00
Dan Abramov 3b1dbccaaf Do a hard reload if hot update can't be applied
Summary:
Hot reloading propagates upwards through the inverse dependency tree — from a file you edited, to the files that import it, and so on. However, we can't always reevaluate everything. Many core infra modules can't run twice, and also the more you run, the more the risk of encountering a module with init side effects. So our practical compromise is to stop the propagation when we reach a module whose exports look like React components. We say that such module "accepts" an update. This means that in practice, changes trigger module reevaluation up to the closest component modules from the edited file. (If you edited a component file, it re-executes alone — unless it exports a non-component.)

However, current implementation has a problem. Sometimes there is an inverse dependency path that has no "accepting" modules whatsoever. For example, maybe you're editing some core module, and its inverse dependency tree reaches goes into React Native itself. Or maybe it reaches the entry point with a bunch of side effects that can't be repeated, like registering the app root component.

In the past, such cases would lead to confusing errors like "Expected `FBPrelude.conclude()` to have been called" after hot reload. This was because we kept re-executing modules all the way upwards, even if there is nothing that can accept the update on the path. Eventually we'd reach top-level modules in the import graph that don't like to run twice.

This diff changes the logic so that we *don't attempt* to re-execute the module factories if we know that some inverse dependency path doesn't terminate in a component. In that case we know we simply *can't apply the hot update* because it doesn't stop at a point we can handle, like a React component.

Since the hot update fails in this case, I'm making it fall back to a regular reload. This is similar to how webpack handles a similar situation on the web. This means that hot updates normally don't refresh, but if we can't apply a hot update to this file, we do refresh automatically.

Reviewed By: cpojer

Differential Revision: D15631864

fbshipit-source-id: 52cd1b03739fd760f1b1b1ab8c7276a150cc3c4c
2019-06-07 03:01:36 -07:00
Felix Oghina 63bc4b4aac @build-break Back out "[RN] Remove Map/Set from RN Open Source"
Summary: Backing out D14786123 as it's causing failures on fbandroid/stable.

Differential Revision:
D15693250
Ninja: sheriff

fbshipit-source-id: 526054d4f0dab2a811f2328540e7418ece9810b1
2019-06-06 04:58:26 -07:00
Christoph Nakazawa 022470ce62 Remove Map/Set from RN Open Source
Summary: This moves Map/Set to fb internal. We do not need them in open source any more but we still need this in some apps at FB that use an old version of JSC.

Reviewed By: TheSavior

Differential Revision: D14786123

fbshipit-source-id: 1c49b47d547ad30f2d93c00b44382cf410100b67
2019-06-06 03:08:16 -07:00
Joshua Gross 308d63fe93 console.log shouldn't throw warning if metro isn't running
Summary: When metro is not running, D15559151 caused infinite exceptions (fetch threw an error if it couldn't connect to localhost:8081) which affected UI. Swallow those errors and everything works well, with or without metro.

Reviewed By: yungsters

Differential Revision: D15588623

fbshipit-source-id: d170ea82478545836a7a22a228196c9778e93ef0
2019-05-31 17:08:19 -07:00
Christoph Nakazawa dc0106e4f4 Do not send log messages to Metro when `Platform.isTesting` is set
Summary: Ideally this should fix `//Libraries/FBReactKit:HiPriServerSnapshotTestsFacebookRedbox`.

Reviewed By: PeteTheHeat

Differential Revision: D15578792

fbshipit-source-id: 83dd227122170721c0f33c54e0f0e23e810569ae
2019-05-31 11:13:47 -07:00
Rubén Norte 74f56bd557 Add method to get a segment path without injecting it in the VM
Reviewed By: cpojer

Differential Revision: D15575463

fbshipit-source-id: 0b481c48f02353e0d15e0dec6162850a0e2140e9
2019-05-31 02:33:12 -07:00
Janic Duplessis bccc92dfdd Remove vendored fetch polyfill, update to whatwg-fetch@3.0 (#24418)
Summary:
The original reason for vendoring the fetch polyfill was to remove the default blob response type but this was reverted.

Here's a little history around the fetch polyfill and the blob issue:

- Original commit introducing the vendored polyfill: #19333, the goal was to fix a memory leak because our blob implementation doesn't release resources automatically. Not an ideal fix but since the issue was pretty severe and the infra for a proper fix was not in place.
- This introduced an issue when downloading images using `fetch` which was fixed by #22063 which re-added the default blob content type. However that re-introduced the original fetch memory leak.
- We have better infra now with jsi and I was able to get blob deallocation working, see #24405

Currently the vendored fetch polyfill is useless since it was changed back to the original version. We can just use the npm version again. I also updated to 3.0 which brings better spec compliance and support for cancellation via `AbortController`, https://github.com/github/fetch/releases/tag/v3.0.0.

## Changelog

[General] [Changed] - Remove vendored fetch polyfill, update to whatwg-fetch@3.0
Pull Request resolved: https://github.com/facebook/react-native/pull/24418

Differential Revision: D14932683

Pulled By: cpojer

fbshipit-source-id: 915e3d25978e8b9d7507ed807e7fba45aa88385a
2019-05-31 01:43:00 -07:00
Christoph Nakazawa db9fc38893 Log `console.log` invocations to the Metro terminal.
Summary:
People ask "How do you use `console.log` with React Native?" and there is no good answer. This diff aims to stop people from asking this question.

See https://fb.workplace.com/groups/rn.core/permalink/2372327062999018/ for context.

This logging relies on network requests which can cause logs to show up out-of-order. To reduce the likelihood I queue every log message on the server for a maximum of 200ms. There could be other methods, like using websocket, but that seems more complex than is necessary at least in the beginning.

I considered various throttling strategies because this could be quite chatty and possibly problematic, however I think we can just ship this and iterate based on feedback. On my very underpowered laptop I logged a random number every 10 milliseconds and it didn't cause any issues or slowdown.

Reviewed By: gaearon

Differential Revision: D15559151

fbshipit-source-id: 552001622af0937ae3a37d2bd8c1b96e7ca52020
2019-05-31 00:45:03 -07:00
Dan Nguyen 99bb710617 Revert D15495065: Add method to get a segment path without injecting it in the VM
Differential Revision:
D15495065

Original commit changeset: 6537100d8b6d

fbshipit-source-id: fee8319eaa5461f11ee4ea8d3b9d25e211beb2a8
2019-05-30 15:19:51 -07:00
Tom Sanderson 7fd08e1461 add spec for PlatformConstants (#24928)
Summary:
part of #24875.

## Changelog

[General] [Added] - add TM spec for PlatformConstants
Pull Request resolved: https://github.com/facebook/react-native/pull/24928

Reviewed By: RSNara

Differential Revision: D15551340

Pulled By: fkgozali

fbshipit-source-id: 9de15ff4cfe717f963332868bd873d5147a37506
2019-05-30 14:29:42 -07:00
Rubén Norte 00c0fe7d5b Add method to get a segment path without injecting it in the VM
Reviewed By: cpojer

Differential Revision: D15495065

fbshipit-source-id: 6537100d8b6dbab68603b7333705d7082c88e3f0
2019-05-30 14:24:40 -07:00
James Ide a7a7970e54 Replace more Haste imports with path-based imports (#25001)
Summary:
This is another step in moving RN towards standard path-based requires, updating more code to use path-based requires. See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail.

## Changelog

[General] [Changed] - Replace more Haste imports with path-based imports
Pull Request resolved: https://github.com/facebook/react-native/pull/25001

Differential Revision: D15467829

Pulled By: cpojer

fbshipit-source-id: 58c364bb4c1c757689907d5ed0d0f3fac0e22f3f
2019-05-23 00:51:31 -07:00
Jean Regisser db0ec66341 Add spec for Timing (#24889)
Summary:
Part of #24875

## Changelog

[General] [Added] - Add TurboModule spec for Timing
Pull Request resolved: https://github.com/facebook/react-native/pull/24889

Reviewed By: fkgozali

Differential Revision: D15379559

Pulled By: RSNara

fbshipit-source-id: d254fb4d1cae3533bbd63bf7ec739cebc6ca14b0
2019-05-22 13:10:25 -07:00
Wojteg1337 94029eee54 Add spec for HeapCapture (#24899)
Summary:
Part of #24875, adds a spec for HeapCapture

## Changelog

[General] [Added] - TM Spec for HeapCapture
Pull Request resolved: https://github.com/facebook/react-native/pull/24899

Reviewed By: fkgozali

Differential Revision: D15393464

Pulled By: RSNara

fbshipit-source-id: d8778285753ce8dbc87204ecfbddfa7339acd264
2019-05-22 13:10:25 -07:00
Michał Pierzchała 8ea749ad3e Add spec for ExceptionsManager (#24900)
Summary:
Part of #24875, adds a spec for ExceptionsManager

## Changelog

[General] [Added] - TM Add spec for ExceptionsManager
Pull Request resolved: https://github.com/facebook/react-native/pull/24900

Reviewed By: fkgozali

Differential Revision: D15434006

Pulled By: RSNara

fbshipit-source-id: 1a505744a84c0c4ac3a9fac6c91a391fbd8a9f46
2019-05-22 13:10:24 -07:00
Jean Regisser 163fb08792 Add spec for SourceCode (#24901)
Summary:
Part of #24875

## Changelog

[General] [Added] - Add TurboModule spec for SourceCode
Pull Request resolved: https://github.com/facebook/react-native/pull/24901

Reviewed By: fkgozali

Differential Revision: D15391727

Pulled By: rickhanlonii

fbshipit-source-id: 9d4622d809efdc3955d435c5a51b72c38cedccc5
2019-05-22 03:27:54 -07:00
Mehdi Mulani 5bb2277245 Move native version check to DEV only
Summary: This check isn't needed in prod as the bundle is served with the app. In dev mode it's possible to have native and JS out of sync.

Reviewed By: yungsters

Differential Revision: D15268485

fbshipit-source-id: 9aeeb6cf5ca91baa90b85e18c848c3b10d85b0f7
2019-05-14 17:46:02 -07:00