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

'Scala.js Com failed: ECONNREFUSED' for Com runs with Node.js 17 #12

Closed
sjrd opened this issue Nov 2, 2021 · 2 comments
Closed

'Scala.js Com failed: ECONNREFUSED' for Com runs with Node.js 17 #12

sjrd opened this issue Nov 2, 2021 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sjrd
Copy link
Member

sjrd commented Nov 2, 2021

It seems that our Com setup for the Node.js env is completely broken on Node.js 17. The symptom in a Scala.js application is

[info] Fast optimizing /localhome/doeraene/projects/scalajs/test-suite/js/.2.12/target/scala-2.12/scalajs-test-suite-test-fastopt
Scala.js Com failed: Error: connect ECONNREFUSED ::1:40091
[error] stack trace is suppressed; run last testSuite2_12 / Test / loadedTestFrameworks for the full output
[error] (testSuite2_12 / Test / loadedTestFrameworks) org.scalajs.testing.common.RPCCore$ClosedException: org.scalajs.testing.adapter.JSEnvRPC$RunTerminatedException
[error] Total time: 49 s, completed Nov 2, 2021 4:31:29 PM

The test suite of this repo indeed fails on Node.js 17.0.1, whereas it passes on 16.13.0:

sbt:root> scalajs-env-nodejs/test
[info] compiling 1 Scala source to /localhome/doeraene/projects/scalajs-js-envs/js-envs/target/scala-2.12/classes ...
[error] Test org.scalajs.jsenv.test.RunTests.catchExceptionTest[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.041 sec
[error] Test org.scalajs.jsenv.test.RunTests.multiCloseAfterTerminatedTest[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.036 sec
[error] Test org.scalajs.jsenv.test.RunTests.defaultFilesystem[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.039 sec
[error] Test org.scalajs.jsenv.test.RunTests.allowScriptTags[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.038 sec
[error] Test org.scalajs.jsenv.test.RunTests.percentageTest[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.04 sec
[error] Test org.scalajs.jsenv.test.RunTests.fastCloseTest[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.038 sec
[error] Test org.scalajs.jsenv.test.RunTests.utf8Test[config = Node.js, withCom = true] failed: closing a ComRun failed unexpectedly, took 0.037 sec
[error] Test org.scalajs.jsenv.test.TimeoutRunTests.basicTimeoutTest[config = Node.js, withCom = true] failed: reached end of stream, took 0.044 sec
[error] Test org.scalajs.jsenv.test.TimeoutRunTests.intervalTest[config = Node.js, withCom = true] failed: reached end of stream, took 0.038 sec
[error] Test org.scalajs.jsenv.test.ComTests.separateComStdoutTest[config = Node.js] failed: no messages left and run has completed, took 0.039 sec
[error] Test org.scalajs.jsenv.test.ComTests.basicTest[config = Node.js] failed: no messages left and run has completed, took 0.038 sec
[error] Test org.scalajs.jsenv.test.ComTests.jsExitsOnMessageTest[config = Node.js] failed: no messages left and run has completed, took 0.039 sec
[error] Test org.scalajs.jsenv.test.ComTests.largeMessageTest[config = Node.js] failed: no messages left and run has completed, took 0.052 sec
[error] Test org.scalajs.jsenv.test.ComTests.highCharTest[config = Node.js] failed: no messages left and run has completed, took 0.037 sec
[error] Test org.scalajs.jsenv.test.ComTests.multiEnvTest[config = Node.js] failed: no messages left and run has completed, took 0.046 sec
[error] Test org.scalajs.jsenv.test.ComTests.noInitTest[config = Node.js] failed: closing a ComRun failed unexpectedly, took 0.041 sec
[error] Test org.scalajs.jsenv.test.TimeoutComTests.noImmediateCallbackTest[config = Node.js] failed: closing a ComRun failed unexpectedly, took 0.037 sec
[error] Test org.scalajs.jsenv.test.TimeoutComTests.noMessageTest[config = Node.js] failed: closing a ComRun failed unexpectedly, took 0.037 sec
[error] Test org.scalajs.jsenv.test.TimeoutComTests.intervalSendTest[config = Node.js] failed: no messages left and run has completed, took 0.038 sec
[error] Test org.scalajs.jsenv.test.TimeoutComTests.delayedReplyTest[config = Node.js] failed: no messages left and run has completed, took 0.039 sec
[error] Test org.scalajs.jsenv.test.TimeoutComTests.delayedInitTest[config = Node.js] failed: no messages left and run has completed, took 0.039 sec
[error] Failed: Total 42, Failed 21, Errors 0, Passed 21
[error] Failed tests:
[error]         org.scalajs.jsenv.nodejs.NodeJSSuite
[error] (scalajs-env-nodejs / Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 7 s, completed Nov 2, 2021 4:37:55 PM

This issue makes any test task in a Scala.js project completely unusable.

@sjrd sjrd added the bug Something isn't working label Nov 2, 2021
@sjrd sjrd self-assigned this Nov 2, 2021
@sjrd sjrd added this to the v1.2.1 milestone Nov 2, 2021
@sjrd
Copy link
Member Author

sjrd commented Nov 2, 2021

Found it. It is an instance of the upstream issue nodejs/node#40537, which is a consequence of an intended change of behavior nodejs/node#39987. The JVM server for the Com runs on IPv4, but Node.js now tries to connect to it via IPv6.

Workaround

As a workaround, pass the --dns-result-order=ipv4first option to the Node.js environment, using

new NodeJSEnv(NodeJSEnv.Config().withArgs(List("--dns-result-order=ipv4first")))

For example, in an sbt build, that would be in a setting like

import org.scalajs.jsenv.nodejs.NodeJSEnv

jsEnv := new NodeJSEnv(NodeJSEnv.Config().withArgs(List("--dns-result-order=ipv4first")))

@sjrd sjrd closed this as completed in c27f0b7 Nov 2, 2021
sjrd added a commit that referenced this issue Nov 2, 2021
Fix #12: Force the server and client of Node.js Com to use IPv4.
@sjrd
Copy link
Member Author

sjrd commented Nov 3, 2021

New workaround until Scala.js v1.8.0

We have now published scalajs-env-nodejs v1.2.1, which contains a proper fix to this issue. It will be included in Scala.js 1.8.0, but that is not for tomorrow. In the meantime, you may force scalajs-env-nodejs v1.2.1 to be used, even with older Scala.js versions, with the following setting in project/plugins.sbt :

libraryDependencies += "org.scala-js" %% "scalajs-env-nodejs" % "1.2.1"

Atry added a commit to Atry/Binding.scala that referenced this issue Nov 6, 2021
morgen-peschke added a commit to morgen-peschke/fuuid that referenced this issue Feb 21, 2023
lolgab added a commit to lolgab/scala-js-env-jsdom-nodejs that referenced this issue Apr 1, 2023
This is needed to fix this issue scala-js/scala-js-js-envs#12
that is fixed in the latest version of `scalajs-env-nodejs`
To share the version between build and meta-build I created a Scala
file which I then syslinked to project/project/ by doing:
```
cd project/project
ln -s ../MetaBuildShared.scala
```
szeiger added a commit to szeiger/sjsonnet that referenced this issue Apr 11, 2023
The CI image was updated and we're hitting scala-js/scala-js-js-envs#12 on 1.4.0.
szeiger pushed a commit to databricks/sjsonnet that referenced this issue Apr 11, 2023
pathikrit added a commit to pathikrit/full-stack-scala-web-app that referenced this issue Sep 1, 2023
sjrd added a commit to sjrd/portable-scala-reflect that referenced this issue May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant