class Main {
public static function main():Void {
haxe.MainLoop.addThread(() -> trace("this prints"));
haxe.Timer.delay(() -> {
haxe.MainLoop.addThread(() -> trace("this does not print"));
}, 0);
}
}
Expected both to print, but only the first trace works. This is not a problem with logging – I verified by setting a value on the global object like so:
class Main {
public static function main():Void {
js.Syntax.code("global.someTestValue = 0");
haxe.MainLoop.addThread(() -> js.Syntax.code("global.someTestValue = 1"));
haxe.Timer.delay(() -> {
haxe.MainLoop.addThread(() -> js.Syntax.code("global.someTestValue = 2"));
}, 0);
haxe.Timer.delay(() -> trace(js.Syntax.code("global.someTestValue")), 100);
}
}
(Outputs 1.)
Compiled with haxe -lib hxnodejs -main Main -js test.js and executed with node test.js. Node version 8.5.0.
Expected both to print, but only the first
traceworks. This is not a problem with logging – I verified by setting a value on the global object like so:(Outputs
1.)Compiled with
haxe -lib hxnodejs -main Main -js test.jsand executed withnode test.js. Node version 8.5.0.