Back out "correct stack traces in flipper ui"

Summary:
Original commit changeset: 09da568db0dd

Original Phabricator Diff: D50015828

Reviewed By: lblasa

Differential Revision: D50168198

fbshipit-source-id: 0fe22ac881365cfe6d1d21babbcddc6f1fae314b
This commit is contained in:
Anton Kastritskiy
2023-10-11 04:21:54 -07:00
committed by Facebook GitHub Bot
parent 9f22952ef2
commit 114a60d510
3 changed files with 6 additions and 20 deletions

View File

@@ -48,7 +48,6 @@
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"reselect": "^4.1.8", "reselect": "^4.1.8",
"semver": "^7.5.4", "semver": "^7.5.4",
"stacktrace-js": "2.0.2",
"uuid": "^8.3.2" "uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -14,7 +14,6 @@ import Button from './Button';
import View from './View'; import View from './View';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import React from 'react'; import React from 'react';
import StackTrace from 'stacktrace-js';
const ErrorBoundaryContainer = styled(View)({ const ErrorBoundaryContainer = styled(View)({
overflow: 'auto', overflow: 'auto',
@@ -41,7 +40,6 @@ type ErrorBoundaryProps = {
type ErrorBoundaryState = { type ErrorBoundaryState = {
error: Error | null | undefined; error: Error | null | undefined;
mappedStack: string | null;
}; };
/** /**
@@ -53,26 +51,17 @@ export default class ErrorBoundary extends Component<
> { > {
constructor(props: ErrorBoundaryProps, context: Object) { constructor(props: ErrorBoundaryProps, context: Object) {
super(props, context); super(props, context);
this.state = {error: null, mappedStack: null}; this.state = {error: null};
} }
componentDidCatch(err: Error, errorInfo: ErrorInfo) { componentDidCatch(err: Error, errorInfo: ErrorInfo) {
// eslint-disable-next-line flipper/no-console-error-without-context // eslint-disable-next-line flipper/no-console-error-without-context
console.error(err, errorInfo.componentStack, 'ErrorBoundary'); console.error(err, errorInfo.componentStack, 'ErrorBoundary');
this.setState({error: err}); this.setState({error: err});
// eslint-disable-next-line promise/no-promise-in-callback
StackTrace.fromError(err)
.then((frames) => {
const mappedStack = frames.map((frame) => frame.toString()).join('\n');
this.setState({error: err, mappedStack});
})
.catch((e) => {
console.log('[stacktrace-js] failed to extract stack trace', e);
});
} }
clearError = () => { clearError = () => {
this.setState({error: null, mappedStack: null}); this.setState({error: null});
}; };
render() { render() {
@@ -90,11 +79,9 @@ export default class ErrorBoundary extends Component<
return ( return (
<ErrorBoundaryContainer grow> <ErrorBoundaryContainer grow>
<Heading>{heading}</Heading> <Heading>{heading}</Heading>
{this.props.showStack !== false && ( {this.props.showStack !== false &&
<ErrorBoundaryStack> 'Look in the console for correct stack traces.'}
{this.state.mappedStack ?? 'Loading stack trace...'} <br />
</ErrorBoundaryStack>
)}
<Button onClick={this.clearError}>Clear error and try again</Button> <Button onClick={this.clearError}>Clear error and try again</Button>
</ErrorBoundaryContainer> </ErrorBoundaryContainer>
); );

View File

@@ -14547,7 +14547,7 @@ stacktrace-gps@^3.0.4:
source-map "0.5.6" source-map "0.5.6"
stackframe "^1.3.4" stackframe "^1.3.4"
stacktrace-js@2.0.2, stacktrace-js@^2.0.2: stacktrace-js@^2.0.2:
version "2.0.2" version "2.0.2"
resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-2.0.2.tgz#4ca93ea9f494752d55709a081d400fdaebee897b" resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-2.0.2.tgz#4ca93ea9f494752d55709a081d400fdaebee897b"
integrity sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg== integrity sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg==