databricks-sql-nodejs icon indicating copy to clipboard operation
databricks-sql-nodejs copied to clipboard

Error When Freezing Array.prototype

Open BikashMcKinsey opened this issue 1 year ago • 2 comments

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:

  1. Run the application.
  2. Observe the error related to the at method.

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

BikashMcKinsey avatar Apr 12 '24 10:04 BikashMcKinsey

Hi @BikashMcKinsey! Please try v1.8.4 and let me know if the issue is fixed or still reproduces. Thanks!

kravets-levko avatar Apr 19 '24 17:04 kravets-levko

@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

BikashMcKinsey avatar Apr 22 '24 05:04 BikashMcKinsey