-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Assign ApiDOM elements to structured errors. Currently we're avoiding assigning ApiDOM elements to structured errors as the concern was that we can introduce memory leaks. Instead we're assigning element type and source maps (if available) to structured errors. After further deep research it has been determined that assigning ApiDOM elements to structured errors is really not an issue unless error instances are somehow retained (we don't do that in any way and future logging system will not retain errors as well).
The only actual concern are Unexpected Mutations: Since we're retaining a reference to the original object, any modifications to that object will be reflected in the error instance as well. This can lead to unexpected behaviors if, for example, you're inspecting the error later and the data has changed. This problem can be resolved by using a deep copy of the ApiDOM element if this is a concern.