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

ES6 Promise polyfill failing in some environments #396

Closed
kytart opened this issue May 2, 2018 · 0 comments
Closed

ES6 Promise polyfill failing in some environments #396

kytart opened this issue May 2, 2018 · 0 comments

Comments

@kytart
Copy link

kytart commented May 2, 2018

Hello,

So, I'm developing an app for LG WebOS 2. I write it in ES6, build it with webpack and transpile it to ES5 with babel loader. I'm using babel polyfill like this

import "babel-polyfill";

in the beginning of the app. Everything is standard so far.

I'm aware of the fact that most people probably don't develop for WebOS so let me just say that it's a regular modern web browser and supports everything a regular browser supports.

In normal app there is no problem. But I'm trying to use web workers, which WebOS supports. My web worker code uses some modules I've written for the main app and those modules use stuff like promises, generators, etc. I want to use those the same way I'd use them in the main app so that's why I'm also using babel-polyfill in the web worker code. And here is the problem.

When I run the web worker, it throws an error

TypeError: Expected at least one argument

on this line.

// modules/_microtask.js line 43
var promise = Promise.resolve();

I'm not exactly sure why but there seems to a problem with the fact that when Promise is polyfilled, Promise.resolve is defined as a function that expects one argument here.

// modules/es6.promise.js line 203
OwnPromiseCapability = function () {
    var promise = new Internal();
    this.promise = promise;
    this.resolve = ctx($resolve, promise, 1);
    this.reject = ctx($reject, promise, 1);
  };

while on the line that it failed it's called without any arguments. It's probably a property of the environment in which the web worker runs on WebOS. When I explicitly changed the line in my built code to

var promise = Promise.resolve(undefined);

it works.

Maybe the line should be changed to this to prevent errors like this in exotic environments. I don't see any other solution.

kytart added a commit to kytart/core-js that referenced this issue May 3, 2018
@kytart kytart mentioned this issue May 3, 2018
zloirock added a commit that referenced this issue May 5, 2018
@zloirock zloirock closed this as completed May 5, 2018
zloirock added a commit that referenced this issue May 5, 2018
zloirock pushed a commit that referenced this issue May 5, 2018
zloirock added a commit that referenced this issue May 5, 2018
zloirock pushed a commit that referenced this issue May 7, 2018
zloirock added a commit that referenced this issue May 7, 2018
zloirock added a commit that referenced this issue May 14, 2018
zloirock pushed a commit that referenced this issue May 14, 2018
zloirock added a commit that referenced this issue May 18, 2018
zloirock pushed a commit that referenced this issue May 26, 2018
zloirock pushed a commit that referenced this issue May 26, 2018
zloirock added a commit that referenced this issue May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants