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

Throw error on invalid @track/@api fields #3408

Open
Tracked by #2964
nolanlawson opened this issue Mar 21, 2023 · 5 comments
Open
Tracked by #2964

Throw error on invalid @track/@api fields #3408

nolanlawson opened this issue Mar 21, 2023 · 5 comments

Comments

@nolanlawson
Copy link
Contributor

nolanlawson commented Mar 21, 2023

E.g. in this class:

export default class Text {
  @api foo = 1;
            
  get foo() {}
  set foo(value) {}
}

... today we don't throw an error in prod mode (or the compiler), but we should. This would be a backwards-incompatible change.

Related: #2515 W-9927596

@nolanlawson nolanlawson changed the title Throw error, don't log error, on duplicate @track/@api fields Throw error, don't log error, on invalid @track/@api fields Mar 21, 2023
@nolanlawson
Copy link
Contributor Author

There are also cases where the wire name is invalid, and currently we log but should throw.

@nolanlawson nolanlawson changed the title Throw error, don't log error, on invalid @track/@api fields Throw error on invalid @track/@api fields Apr 4, 2023
@timsalesforce
Copy link

We have an Investigation where in debug mode, a flexipage fails to render at all if there is an LWC error (duplicate property). This happens because register.validateObservedField is throwing an error. In this change we changed it to log-only, and now the page at least can render, and the error is logged. However, there is a comment saying we should change the log to throw. But if we do that, the problem will resurface. It is a very bad user experience to hose the entire flexipage for an error in an included LWC. So my hope is that we do not throw an Error, or throw it in such a way that it doesn't hork the entire page. Ravi and I looked at it for a while and don't thing there is a good way to achieve this, but maybe its possible to do. If not, I think we should continue to log-only.

@nolanlawson
Copy link
Contributor Author

For now, we will definitely do log-only, yeah. This is in our breaking changes wishlist (#2964), so we definitely acknowledge that it would be a breaking change to change this behavior in prod mode. It may be possible to do with API versioning.

@timsalesforce
Copy link

Thanks Nolan! Even in debug mode, the result of a completely broken flexipage is no bueno.

@nolanlawson
Copy link
Contributor Author

Yep, that was exactly the point of 4a66fe4 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants