Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack trace on worklet factory crash #5197

Merged
merged 10 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/src/examples/WorkletFactoryCrashExample.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React from 'react';
import { Button, StyleSheet, View, Text } from 'react-native';

export default function App() {
function handleOnPress() {
function badWorklet() {
'worklet';
// @ts-expect-error
unexistingVariable;
}
}

return (
<View style={styles.container}>
<Text style={styles.text}>
Clicking the button below should give a stack trace that denotes the
error in `badWorklet` function, pointing to `unexistingVariable` usage.
tomekzaw marked this conversation as resolved.
Show resolved Hide resolved
</Text>
<Button title={'Crash me'} onPress={handleOnPress} />
tomekzaw marked this conversation as resolved.
Show resolved Hide resolved
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
text: {
textAlign: 'center',
},
});
6 changes: 6 additions & 0 deletions app/src/examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import WobbleExample from './WobbleExample';
import WorkletExample from './WorkletExample';
import WorkletRuntimeExample from './WorkletRuntimeExample';
import NestedLayoutAnimationConfig from './LayoutAnimations/NestedLayoutAnimationConfig';
import WorkletFactoryCrash from './WorkletFactoryCrashExample';

interface Example {
icon?: string;
Expand Down Expand Up @@ -412,6 +413,11 @@ export const EXAMPLES: Record<string, Example> = {
title: 'Log test',
screen: LogExample,
},
WorkletFactoryCrash: {
icon: '🏭',
title: 'Worklet factory crash',
screen: WorkletFactoryCrash,
},

// Old examples

Expand Down