Skip to content

Commit 2870f1d

Browse files
authored
fix(vue): property access on undefined in errorHandler (#5279)
1 parent d4c153b commit 2870f1d

File tree

3 files changed

+415
-3
lines changed

3 files changed

+415
-3
lines changed

packages/vue/src/errorhandler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ export const attachErrorHandler = (app: Vue, options: Options): void => {
1717
trace,
1818
};
1919

20-
if (vm && options.attachProps) {
20+
if (options.attachProps && vm) {
2121
// Vue2 - $options.propsData
2222
// Vue3 - $props
23-
metadata.propsData = vm.$options.propsData || vm.$props;
23+
if (vm.$options && vm.$options.propsData) {
24+
metadata.propsData = vm.$options.propsData;
25+
} else if (vm.$props) {
26+
metadata.propsData = vm.$props;
27+
}
2428
}
2529

2630
// Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time.

packages/vue/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type ViewModel = {
1717
$root: ViewModel;
1818
$parent?: ViewModel;
1919
$props: { [key: string]: any };
20-
$options: {
20+
$options?: {
2121
name?: string;
2222
propsData?: { [key: string]: any };
2323
_componentTag?: string;

0 commit comments

Comments
 (0)