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

19 Коммитов

Автор SHA1 Сообщение Дата
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
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 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
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
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
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
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
James Ide 0ee5f68929 Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749)
Summary:
This is the next step in moving RN towards standard path-based requires. All the requires in `Libraries` have been rewritten to use relative requires with a few exceptions, namely, `vendor` and `Renderer/oss` since those need to be changed upstream. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change.

See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail.

[General] [Changed] - Migrate "Libraries" from Haste to standard path-based requires
Pull Request resolved: https://github.com/facebook/react-native/pull/24749

Differential Revision: D15258017

Pulled By: cpojer

fbshipit-source-id: a1f480ea36c05c659b6f37c8f02f6f9216d5a323
2019-05-08 08:48:59 -07:00
Christoph Nakazawa c36151ecef Do not overwrite Object.freeze
Summary: Now that React Native ships with a newer version of JSC, we do not need this code to wrap `Object.freeze` any longer.

Reviewed By: mmmulani

Differential Revision: D14779239

fbshipit-source-id: 1a6e1a9c7f4312572bd08ba604fa8c9d6b1927e1
2019-04-04 10:53:34 -07:00
Ben Newman 90850cace9 Critical improvements for Map and Set polyfills.
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/21492

Differential Revision: D10288094

Pulled By: cpojer

fbshipit-source-id: b1ca7344dda3043553be6945614b439a0f42a46a
2019-01-28 01:52:14 -08:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Miguel Jimenez Esun 834b9d4e6e Adding @email tags to most of the tests
Reviewed By: rafeca

Differential Revision: D6185623

fbshipit-source-id: 30df83288fe85516d8d5a1617a4fb8fea826ed6f
2017-11-02 06:25:03 -07:00
Héctor Ramos Ortiz 1dca01b532 Remove ReactNativeVersionCheck __DEV__ gating, print error instead of throwing
Reviewed By: cblappert

Differential Revision: D6192020

fbshipit-source-id: 026f376d6d43ab3de188f94f2a4d5f0cf485733c
2017-10-31 14:28:12 -07:00
Mike Grabowski 4e1dfa48a2 Fix test suite when running on a feature branch
Summary:
Test suite for React Native version check relies on `ReactNativeVersion.js` file that is modified on a release branch (it contains values of a real version, not zeros).

That makes it impossible for the build to pass: https://circleci.com/gh/facebook/react-native/23494

This PR mocks it with zero values, just like we mock it in other suites. I am not sure if that is desired, but works for now.

CC ide
Closes https://github.com/facebook/react-native/pull/16464

Differential Revision: D6100285

Pulled By: hramos

fbshipit-source-id: 784f7e14f5283403f3fa518940565e1ef19dd398
2017-10-19 13:53:27 -07:00
James Ide 7733d40237 Move JS-native version check to its own module + unit tests + prefix Obj-C macro w/RCT
Summary:
- The version check that ensures the JS and native versions match is now in its own module for two reasons: it is easier to test and it allows react-native-windows to override just this module to implement its own version check (ex: more advanced checks for RNW-specific code).
- Added unit tests for the version checking to specify its behavior more clearly, including parity between dev and prod to avoid prod-only behavior and mitigate SEVs.
- Prefixed the Obj-C `#define` with `RCT_` to conform with other RN globals.
Closes https://github.com/facebook/react-native/pull/16403

Differential Revision: D6068491

Pulled By: hramos

fbshipit-source-id: 2b255b93982fb9d1b655fc62cb17b126bd5a939a
2017-10-16 14:30:34 -07:00