JS: putStrLn is executed asynchronously in browser
Summary
The console.log
generated by the JS backend for a putStrLn
is executed asynchronously in browsers.
Steps to reproduce
See attached repro case Test.hs
.
$ rm -rf Test Test.hi Test.o Test.jsexe; javascript-unknown-ghcjs-ghc-9.8.2 -v -dcore-lint Test.hs > ghc.log 2>&1 && ./Test
one
two
Loading Test.jsexe/index.html
is a browser and opening the JS console log will show:
two all.js:44450:24
one all.js:8575:17
Expected behavior
The putStrLn
to be executed synchronously, as in the native backend and as interpreted by nodejs
.
Environment
- GHC version used: 9.8.2 JS backend
- Nodejs version used: v20.11.0
- Google Chrome version used: 121.0.6167.184 (Official build) (64 bit)
- Mozilla Firefox version used: 123.0 (64 bit)
Optional:
- Operating System:
- System Architecture:
$ uname -a
Linux abcde 6.7.5-gentoo #1 SMP Mon Feb 19 15:51:31 CET 2024 x86_64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz GenuineIntel GNU/Linux