Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
12 changes: 8 additions & 4 deletions packages/core/src/utils/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Primitive } from '../types-hoist/misc';
import { isSyntheticEvent, isVueViewModel } from './is';
import { isSyntheticEvent } from './is';
import { convertToPlainObject } from './object';
import { getFunctionName, getVueInternalName } from './stacktrace';
import { getFunctionName } from './stacktrace';

type Prototype = { constructor?: (...args: unknown[]) => unknown };
// This is a hack to placate TS, relying on the fact that technically, arrays are objects with integer keys. Normally we
Expand Down Expand Up @@ -216,8 +216,12 @@ function stringifyValue(
return '[Document]';
}

if (isVueViewModel(value)) {
return getVueInternalName(value);
if (
typeof value === 'object' &&
value !== null &&
('__isVue' in value || '_isVue' in value || '__v_isVNode' in value)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property existence check differs from original truthiness check

Low Severity

The inlined check uses '__isVue' in value || '_isVue' in value || '__v_isVNode' in value which tests property existence, while the original isVueViewModel tested property truthiness (value.__isVue || value._isVue || value.__v_isVNode). The in operator returns true even if the property value is false, 0, null, or undefined. An object with e.g. { __isVue: false } would now be incorrectly identified as a Vue ViewModel when it previously would not have been. The PR claims identical behavior, but this is a subtle semantic difference.

Additional Locations (1)
Fix in Cursor Fix in Web

) {
return '__v_isVNode' in value && value.__v_isVNode ? '[VueVNode]' : '[VueViewModel]';
}

// React's SyntheticEvent thingy
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/utils/string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isRegExp, isString, isVueViewModel } from './is';
import { getVueInternalName } from './stacktrace';
import { isRegExp, isString } from './is';

export { escapeStringForRegex } from '../vendor/escapeStringForRegex';

Expand Down Expand Up @@ -76,13 +75,14 @@ export function safeJoin(input: unknown[], delimiter?: string): string {
for (let i = 0; i < input.length; i++) {
const value = input[i];
try {
// This is a hack to fix a Vue3-specific bug that causes an infinite loop of
// console warnings. This happens when a Vue template is rendered with
// an undeclared variable, which we try to stringify, ultimately causing
// Vue to issue another warning which repeats indefinitely.
// Vue3 ViewModels and VNodes can cause infinite console warning loops when stringified
// see: https://github.com/getsentry/sentry-javascript/pull/8981
if (isVueViewModel(value)) {
output.push(getVueInternalName(value));
if (
typeof value === 'object' &&
value !== null &&
('__isVue' in value || '_isVue' in value || '__v_isVNode' in value)
) {
output.push('__v_isVNode' in value && value.__v_isVNode ? '[VueVNode]' : '[VueViewModel]');
} else {
output.push(String(value));
}
Expand Down
Loading