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(core/component/engines/vue3): do not log component info for specific warnings #1474

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.?? (2024-11-??)

#### :bug: Bug Fix

* Omit detailed component information to prevent event loop freezing associated
with certain warnings. Vue uses a `get` trap within the proxy to verify the presence
of a property in the instance. Accessing undefined properties via the `getComponentInfo` method
during a warn or error handler will trigger infinite recursion. `core/component/engines/vue3`

## v4.0.0-beta.149 (2024-10-31)

#### :rocket: New Feature
Expand Down
9 changes: 9 additions & 0 deletions src/core/component/engines/vue3/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]

## v4.0.0-beta.?? (2024-11-??)

#### :bug: Bug Fix

* Omit detailed component information to prevent event loop freezing associated
with certain warnings. Vue uses a `get` trap within the proxy to verify the presence
of a property in the instance. Accessing undefined properties via the `getComponentInfo` method
during a warn or error handler will trigger infinite recursion.

## v4.0.0-beta.141 (2024-10-03)

#### :bug: Bug Fix
Expand Down
15 changes: 12 additions & 3 deletions src/core/component/engines/vue3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ Vue.config.errorHandler = (err, vm, info) => {
};

Vue.config.warnHandler = (msg, vm, trace) => {
logger.warn('warnHandler', msg, trace, getComponentInfo(vm));
// It prevents event loop freeze (check CHANGELOG for details)
const omitDetails = Object.isString(msg) &&
msg.endsWith('was accessed during render but is not defined on instance.');

logger.warn('warnHandler', msg, trace, getComponentInfo(vm, omitDetails));
};

const
Expand All @@ -29,16 +33,21 @@ const

/**
* Returns a dictionary with information for debugging or logging the component
*
* @param component
* @param omitDetails
shining-mind marked this conversation as resolved.
Show resolved Hide resolved
*/
function getComponentInfo(component: Nullable<ComponentPublicInstance | ComponentInterface>): Dictionary {
function getComponentInfo(
component: Nullable<ComponentPublicInstance | ComponentInterface>,
omitDetails: boolean = false
): Dictionary {
if (component == null) {
return {
name: UNRECOGNIZED_COMPONENT_NAME
};
}

if ('componentName' in component) {
if ('componentName' in component && !omitDetails) {
shining-mind marked this conversation as resolved.
Show resolved Hide resolved
return {
name: getComponentName(component),
...component.getComponentInfo?.()
Expand Down
Loading