Skip to content

Removal of _this# variables in JS SDK v3.5.0 #1599

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

Closed
4 tasks done
aarondill opened this issue Nov 7, 2022 · 5 comments · Fixed by #1600
Closed
4 tasks done

Removal of _this# variables in JS SDK v3.5.0 #1599

aarondill opened this issue Nov 7, 2022 · 5 comments · Fixed by #1600
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version

Comments

@aarondill
Copy link

aarondill commented Nov 7, 2022

New Issue Checklist

Issue Description

Removal of _this# variables in JS SDK v3.5.0

Within the Parse JS SDK, variables intended to capture the context of this in certain contexts are generally called _this, optionally followed by a number(i.e. _this1), for the purpose of this report, I will call them _this variables, ignoring the number, to increase readability and shorten length.

Using simple find tools(i.e. searching for var _this), I found that 17 _this variables were removed from the Javascript SDK between v3.4.4 and v3.5.0. At first glance, this change seems positive, as it reduces memory required by the Parse SDK module, however, as can be seen in issue #1596 and my discovery of the issue causing it the removal of some of these _this variables create issues that can halt functions and throw errors.

It seems possible that the contributor(s) related to the removal of these _this variables was mistaken in the implementation of the this keyword in (at least) functions passed to Promise.then() and therefore errors are thrown by the environment attempting to read properties of this, at times where this evaluates to undefined in strict mode.

It is greatly recommended that each removal of these _this variables is reevaluated and that any necessary variables are reinstantiated into the SDK to avoid futher errors and issues.

Due to insufficient time and understanding of the code base of the Parse SDK, I am incapable of checking each and every removal, however the recent errors caused by these removals should certainly be considered and every precaution should be taken to prevent further issues from arising.

Steps to reproduce

Due to the large scale of this issue, and the potential for some removals to be valid, I will not produce STP, however STP for the errors in the Query.first and Query.subscribe functions can be seen in issue #1596.

Actual Outcome

For certain functions, typeErrors are thrown and the program is halted.
(Potentially) For others, evaulation is continued and in incorrect value is returned or saved.

Expected Outcome

Correct return values and database writes, without any errors thrown.

Environment

Database

  • Local or remote host: back4app (once more irrelevant)

Client

  • Parse JS SDK version: v3.5.0

Note

Due to the format of this issue, it does not quite fit the issue format, however, for lack of better location, I am placing this under generic issues. Please let me know if there is a better location for this issue.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 7, 2022

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@dblythy
Copy link
Member

dblythy commented Nov 7, 2022

We don't actually directly write any of the distributed code, it is a complied version of the source code in this repo. The compiled code is generated by running npm run build and looking at the /dist directory

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1-alpha.2

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Nov 7, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1-beta.2

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 26, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants