Error When Freezing Array.prototype
In a particular file, the Array.prototype is being frozen which is causing compatibility issues. The issue arises when the at method is added to the Array.prototype after it has been frozen, resulting in an error.
Steps to reproduce:
- Run the application.
- Observe the error related to the
atmethod.
Expected behavior: The application should run without errors.
Actual behavior:
An error occurs when running the application due to the Array.prototype being frozen before the at method is added.
Proposed solution:
Modify the code to conditionally add the at method to the Array.prototype only if it doesn't already exist
Hi @BikashMcKinsey! Please try v1.8.4 and let me know if the issue is fixed or still reproduces. Thanks!
@kravets-levko Still happens with the current fix but this fixes it
ArrayConstructors.forEach((ArrayConstructor) => {
if (!ArrayConstructor.prototype.at) {
var _a;
ArrayConstructor.prototype.at = (_a = ArrayConstructor.prototype.at) !== null && _a !== void 0 ? _a : at;
}
});
Here's the error
Fatal Error: TypeError: Cannot assign to read only property 'at' of object '[object Array]'
Already have the PR there, https://github.com/databricks/databricks-sql-nodejs/pull/243/files