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

Error When Freezing Array.prototype #244

Open
BikashMcKinsey opened this issue Apr 12, 2024 · 2 comments
Open

Error When Freezing Array.prototype #244

BikashMcKinsey opened this issue Apr 12, 2024 · 2 comments

Comments

@BikashMcKinsey
Copy link

BikashMcKinsey commented Apr 12, 2024

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 BikashMcKinsey changed the title Issue: Error When Freezing Array.prototype Error When Freezing Array.prototype Apr 12, 2024
@kravets-levko
Copy link
Contributor

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

@BikashMcKinsey
Copy link
Author

BikashMcKinsey commented Apr 22, 2024

@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

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

No branches or pull requests

2 participants