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

k6-es6 example not working #1282

Closed
joostmeijles opened this issue Dec 18, 2019 · 9 comments
Closed

k6-es6 example not working #1282

joostmeijles opened this issue Dec 18, 2019 · 9 comments
Assignees

Comments

@joostmeijles
Copy link

The JS compatibility mode documentation (https://docs.k6.io/docs/javascript-compatibility-mode), points to an example that does not work: https://github.com/MStoykov/k6-es6

Running the k6-es6 example results in:

ERRO[0001] TypeError: util.promisify requires a true ES5 environment at file:///C:/Repos/k6-es6/build/app.bundle.js:8:273234(42)
@mstoykov
Copy link
Contributor

@joostmeijles can you provide the script that doesn't work?
Also this is probably better for the k6-es6 repo as it is the one that is trying to do the job of translating ES6+ to ES5.1 that k6 can then run. But lets continue here for now :)

@joostmeijles
Copy link
Author

joostmeijles commented Dec 19, 2019

@mstoykov I cloned Github repo and the followed the steps from the README:

npm install
npm run-script webpack
k6 run build/app.bundle.js

Using Node v10.16.2 and K6 v0.26.0 (dev build, go1.13, windows/amd64) on Windows 10.

@mstoykov
Copy link
Contributor

I was mostly asking for the script that didn't work (or better smaller example that showcases it).
But looking at this again util.promisify is about promises and async stuff and k6 currently doesn't have an event loop, so it's totally normal that running through k6-es6 won't help at all.

Does the script work before you run it through k6-es6, because that will be an interesting problem as well? But in general, if it doesn't work without running it through k6-es6 it is very doubtful it will after.

Also as it is mentioned k6-es6 is a proof-of-concept. I would really prefer it if we can extend it and make it work for everything, but it won't work for anything that k6 conceptually doesn't support

@joostmeijles
Copy link
Author

The problem is that the example uses xml2js.

Simple fix would be to remove that and update the docs with the event loop limitations.

@simskij
Copy link
Contributor

simskij commented Mar 20, 2020

Thank you for your report! I will have a look at this as soon as I get some time on my hands. 🙏🏼

@simskij simskij self-assigned this Mar 20, 2020
@mstoykov
Copy link
Contributor

I did try to make it work, as supposedly it should be able to,but all my tries were in vain.

Fortunately @simskij who has some knowledge about how webpack works will have more success.

@simskij
Copy link
Contributor

simskij commented Apr 23, 2020

Hey,

I've been looking at this for the last couple of days and, unfortunately, it seems like we currently are unable to run xml2js, and cheerio for that matter, in --compatibility-mode=base with only @babel/preset-env due to limits in how webpack polyfills dependencies.

The most memory efficient solution for now seems to be to run it without --compatibility-mode=base, rather than trying to polyfill with for instance @babel/polyfill, which while it works - produces roughly the same result with more effort.

Simme

@simskij
Copy link
Contributor

simskij commented Apr 23, 2020

For future reference:

All of these tests have been run with --vus 100 --paused.

Base Config Memory Consumption Comment
@babel/preset-env and useBuiltIns: 'usage' N/A Errors out
@babel/preset-env, @babel-polyfill and useBuiltIns: 'entry' 6.3GB Requires import in test script
@babel/preset-env and useBuiltIns: 'usage' 6.3GB
@babel/preset-env, @babel-polyfill and useBuiltIns: 'entry' 6.5GB Requires import in test script
@babel/preset-env and useBuiltIns: 'usage' 234mb without cheerio and xml2js

@simskij
Copy link
Contributor

simskij commented Apr 23, 2020

I've updated the docs as suggested. Closing this issue for now.

Thank you for bringing this to our attention!

@simskij simskij closed this as completed Apr 23, 2020
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

3 participants