Skip to content

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

Closed
@aarondill

Description

@aarondill

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions