It seams that in some cases `onReceive` is called before `init`. Adding a buffer for incoming messages before `init` is called should solve this issue. https://github.com/scala-js/scala-js-env-selenium/blob/master/seleniumJSEnv/src/main/scala/org/scalajs/jsenv/selenium/SeleniumComJSRunner.scala#L106