-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
support asynchronous test cases properly #4529
Conversation
test/sandbox.js
Outdated
} while (prev !== stdout); | ||
return stdout; | ||
} : run_code; | ||
} : semver.satisfies(process.version, "<8") ? run_code_vm : function(code, toplevel, timeout) { | ||
return (/async function/.test(code) ? run_code_exec : run_code_vm)(code, toplevel, timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the fact that it differentiates between async test cases and regular ones for perf reasons, but that regex won't catch async arrow functions or when the tokens span multiple lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I forgot to append [WIP]
to this PR − not planning to merge this, just thought I'd clean up the stage a bit so you can have a go when you want to do so 😉
Very cool. Can we force certain tests to be async even without an |
That's very odd. Must be a Windows thing. Can you force a certain Windows unicode code page or something like that?
No surprise there - but at least it works - that's the important thing. It should be possible to squeeze some extra performance from it with a reusable child process and a wire protocol from the main program to avoid the process spawning overhead. |
async
test cases properlyasync
test cases properly
I tried to no avail − it's a Node.js bug, as I can see and print Unicode in Command Prompt without issues. Node.js v15 also screws up the ANSI colour codes, so no surprises there. I have tried to make Node.js use |
Since some test cases creates and modifies global variables, will need to make sure everything's cleaned up properly. And then there's the problem of using any asynchronous API calls which requires extensive rewrites of all the users of |
Could do − as I said earlier, this PR is more of a proof of concept at this stage, as there will be kinks to work out in order for it to work across all Node.js versions and OS platforms. |
BTW |
Great proof of concept in any event. I don't recall whether function*/yield test cases were also limited by the vm sandbox relying on next tick.
I hate that new useless color feature in NodeJS. Should just disable it with that env var NO_COLOR and call it a day. |
b1da9db
to
96ef385
Compare
Right, let's see if my workaround for the newly discovered quirk on Node.js v0.12 works. I've expanded the regex to cover all forms of
Anything that gets scheduled on a queue would escape
At least you only hate that one feature... 😉 |
The dozen non-asynchronous tests using |
Fair point − I was more concerned with |
Looks like what happened to Node.js v0.12 back in #4495 is happening to Node.js v6 as well 👻 |
test.jsif (0) (function() {
/*
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
* abcdefghijklmnopqrstuvwxyz
*/
})();
(function({
[function() {
console.log(typeof f);
}()]: a,
}) {})(0); $ node -v
v6.17.1
$ cat test.js | node
$ node test.js
undefined
$ node -v
v8.17.0
$ cat test.js | node
undefined
$ node test.js
undefined
|
Buffer overflow in Node v6? |
Given the fact that it relies on the destructuring function parameter with computed key to trigger, I'd lean towards some parser bug on the "slow" path, routed by input byte size, which isn't present on the "fast" path. |
3b3b6c3
to
61c3e4b
Compare
exec won't be fast enough for ufuzz and test/reduce without some form of child process reuse - perhaps even a pool of child processes. Might this dual vm/exec sandbox be used for test/compress only for the time being, with ufuzz and test/reduce only using vm? |
Any idea how to make a pool of child processes and perform synchronous send/receive on Node.js? 😅 I'm in no hurry to merge this PR − actually amused that all the tests passed so soon, but will just keep it tracking |
I guess it wouldn't be. Would have to shim Promise support into the compress test runner. |
I've found a performant solution reusing a child process without turning
|
That's the best case − for some reason the variation between runs is huge as well.
Could do, but then these failures are so esoteric, and strictly applies to a code base which showed little intention of tackling them, I'd prefer the existing behaviour of watching v8 die than getting bugged by another false positive TBH. |
The (currently discovered) showstopper for using later version of Node.js for
|
That's fair, I guess it's strictly a V8 issue, not something that can be remedied within uglify minify.
vm is so limited in NodeJS, and its utility is decreasing with each new release. Makes you wonder what use case it was designed for. |
In this PR, is run_code_exec presently used more than it should due to ufuzz generating synchronous programs with variables and functions named |
The kindest thing I can say is "hindsight's 20/20" 😏
Oh that issue is mostly resolved now − My plan is to merge this after the next release − it's just that I've been getting a trickling feed of ufuzz failures on Assuming an uneventful evening I'll make that release tomorrow and we can turn our full attention to watching this PR does wonders 😎 |
82e13a7
to
fbfd852
Compare
Is fuzzing slower now with the hybrid vm/exec sandbox? |
Nothing measurable beyond the usual variations between runs yet. Not helped by the fact that GitHub seems to be having issues with scheduling workflows, or marking one as "Completed" regardless of whether its jobs are running or even started. Whatever they thought to be "resolved" clearly hasn't 🤔 |
Let's hope these don't pop up too frequently 👻 |
I'm trying to grok the transform that avoids a core dump in NodeJS v8.x...
Is the default value |
No, they are not equivalent − but that's alright because Lines 6206 to 6210 in 7793c6c
$ echo '(async (foo = [ ([] = 0), ...0 ]) => 0)();' | uglify-js -bc unused=0
(async (foo = [ [] = 0, ...0 ]) => 0)(); |
Ah, yes of course. The side effects are retained. Thanks. Side note... test/reduce could drop the |
Indeed − taking the ((foo = [ [] = 0, ...0 ]) => 0)(); ... which works on Node.js 6 👻 |
This is the same v8 (non-crashing) bug, but this time // reduced test case (output will differ)
// (beautified)
(async (NaN_2 = 0(...[ ...0, "object" ])) => {})();
// output:
// minify: SyntaxError: Rest parameter must be last formal parameter
// options: {
// "mangle": false,
// "output": {
// "v8": true
// },
// "validate": true
// } |
You can't win 'em all. |
Not sure if you're still experiencing this issue. If so, here's a windows unicode bug workaround: |
Indeed − thanks for the pointer 👍
... I see we share the same enthusiasm 😏 |
Unfortunately we are running into a different Unicode bug than their workaround has provided (and no it's not because Command Prompt doesn't support Unicode by default − the only program that has b0rk3n output is Node.js) |
Specifically, it's the unpaired surrogate characters which are being mistranslated. |
The unicode code page hack |
First thing I tried after Google-fu − does not change any behaviour on later versions of Windows 😏 |
@kzc you may find this interesting 😉
Caveats:
async
is in use, anything relying on Unicode will break (at least on Windows)