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

[Bug] Using super in async method #9935

Open
orlov-vo opened this issue May 3, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@orlov-vo
Copy link

commented May 3, 2019

Bug Report

Current Behavior
I have error RangeError: Maximum call stack size exceeded when I used a super in my async method

Input Code
REPL

class MyClass extends BaseClass {
  async loadEntity() {
    this.website = await this.loadWebsite();
    this.report.setCompany(this.website.company);
    super.loadEntity();
  }
}

Expected behavior/code
It should work without looping

class MyClass extends BaseClass {
  loadEntity() {
    var _this = this,
        _superprop_callLoadEntity = function _superprop_callLoadEntity() {
      return _superprop_callLoadEntity(...arguments); // <= HERE I HAVE LOOPING :(
    };

    return _asyncToGenerator(function* () {
      _this.website = yield _this.loadWebsite();

      _this.report.setCompany(_this.website.company);

      _superprop_callLoadEntity();
    })();
  }

}
@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented May 3, 2019

Hey @orlov-vo! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented May 4, 2019

This is probably impossible to transpile without also transpiling classes. If your targets supported arguments rest/spread, that could would have been transpiled to this:

class MyClass extends BaseClass {
  loadEntity() {
    var _this = this,
        _superprop_callLoadEntity = (...args) =>   super.loadEntity(...args);

    return _asyncToGenerator(function* () {
      _this.website = yield _this.loadWebsite();

      _this.report.setCompany(_this.website.company);

      _superprop_callLoadEntity();
    })();
  }

}

Unfortunatly (...args) => super.loadEntity(...args) doesn't work in some of your targets: for this reason we have to transpile it to a normal function, but then we can't correctly transpie the super reference.

If you add "include": ["transform-classes"] to your preset-env options, it should correctly work.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented May 4, 2019

Oh I might have a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.