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

22 Коммитов

Автор 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
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 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 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
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
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
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
Moti Zilberman 2e8d39bed7 ExceptionsManager: Handle null filenames in symbolicated stack trace gracefully
Summary: If some stack frames in a trace fail to symbolicate (or are genuinely unmapped), their `frame` field will be null, and `ExceptionsManager.js` will currently crash. This diff lets it recover gracefully and show whatever information is available.

Reviewed By: dcaspi

Differential Revision: D15296220

fbshipit-source-id: 2b1006b1354295171b25bfc6230c5b3e0c57f67f
2019-05-14 11:59:46 -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
Moti Zilberman 920632cadb Reuse message when updating redbox with symbolicated JS error
Summary:
On iOS, `RCTRedBox` will not update the displayed stack trace if the message string sent with the update differs from the original error message. As JS errors are shown in two stages - before and after symbolication - there was previously a case where the message would differ between the two `updateExceptionMessage` calls, blocking the update and leaving only the unsymbolicated trace visible. This diff fixes that.

Longer term, we should also change `RCTRedBox`'s logic to rely on the JS-provided `exceptionID` instead of the message string - similar to what we do on Android.

Changelog:
[iOS] [Fixed] - Fix redbox JS symbolication when adding JS engine tag to the message

Reviewed By: sahrens

Differential Revision: D15202524

fbshipit-source-id: 237fc090e88b0c609865e0aed842d6a609c1239a
2019-05-03 12:19:14 -07:00
Michał Pierzchała 49d26eb0c4 cleanup RedBox message and stack output (#24662)
Summary:
Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like):

- [general] filter out some of the internal callsites from the symbolicated stack (I thought about using monospace font for title with code frame, but it looks weird)
- [ios][android] strip ANSI characters (coming from colored Babel code frame) from the error message

I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output.

**JS Code frame:**

|before|after|
|--|--|
|<img width="400" alt="Screenshot 2019-04-30 at 12 32 05" src="https://user-images.githubusercontent.com/5106466/56956590-ef678d80-6b44-11e9-9019-6801f050ab0d.png">|<img width="400" alt="Screenshot 2019-04-30 at 12 52 43" src="https://user-images.githubusercontent.com/5106466/56957302-f42d4100-6b46-11e9-869b-ea9c7ce5b90f.png">|

|before|after|
|--|--|
|![image](https://user-images.githubusercontent.com/5106466/56959472-c8618980-6b4d-11e9-84be-6261d8375f4a.png)|![image](https://user-images.githubusercontent.com/5106466/56959463-bc75c780-6b4d-11e9-9d8b-25ffe46c87cf.png)|

**Filtered stack traces:**

|before|after|
|--|--|
|<img width="50%" alt="Screenshot 2019-04-30 at 12 27 21" src="https://user-images.githubusercontent.com/5106466/56956641-0908d500-6b45-11e9-8cdc-8c2a34a071e5.png"><img width="50%" alt="Screenshot 2019-04-30 at 12 27 28" src="https://user-images.githubusercontent.com/5106466/56956642-0908d500-6b45-11e9-921c-fabfb8515cc0.png">|<img width="100%" alt="Screenshot 2019-04-30 at 12 26 55" src="https://user-images.githubusercontent.com/5106466/56956650-0efeb600-6b45-11e9-9f5f-f10dd69580d1.png">|

There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors.

cc cpojer

[General][Changed] - Cleanup RedBox message and stack output
Pull Request resolved: https://github.com/facebook/react-native/pull/24662

Differential Revision: D15147571

Pulled By: cpojer

fbshipit-source-id: 1de4e521af988fa7fc709b6accd0ddd984388e72
2019-04-30 07:35:14 -07:00
Yue Xu 2b1d8cc54b Add js engine information in React Native error reporting
Summary:
To avoid "js engine: ..." appearing everywhere, only add this information
to the error message when react native is reporting errors to the server.

Reviewed By: yungsters

Differential Revision: D9754371

fbshipit-source-id: a8001480c75ccf93c953c79f26470df678871cb3
2018-09-12 14:01:50 -07: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
Eli White d01ab66b47 Prettier React Native Libraries
Reviewed By: sahrens

Differential Revision: D7961488

fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
2018-05-10 19:10:38 -07:00
Rubén Norte d5e9e55fa3 Remove @providesModule from all modules
Summary:
This PR removes the need for having the `providesModule` tags in all the modules in the repository.

It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`)

* Checked the Flow configuration by running flow on the project root (no errors):

```
yarn flow
```

* Checked the Jest configuration by running the tests with a clean cache:

```
yarn jest --clearCache && yarn test
```

* Checked the Metro configuration by starting the server with a clean cache and requesting some bundles:

```
yarn run start --reset-cache
curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android'
curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios'
```

[INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools.
Closes https://github.com/facebook/react-native/pull/18995

Reviewed By: mjesun

Differential Revision: D7729509

Pulled By: rubennorte

fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
2018-04-25 07:37:10 -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
Pieter De Baets 534bbfac8f Report Java stack from errors from sync native module calls
Reviewed By: mhorowitz

Differential Revision: D5069794

fbshipit-source-id: ede314034a2eb6b063a22dbd6e5d13c8ad66e20c
2017-06-14 09:32:37 -07:00
Pieter De Baets 292cc82d0e Reorganize core JS files
Reviewed By: lexs

Differential Revision: D3987463

fbshipit-source-id: fa8f1d1bea7ed699120b9705ddc1c83767fcf8e4
2016-10-11 10:14:28 -07:00