Skip to content

Question: How to support JSDOMNodeJSEnv?  #4

@xerial

Description

@xerial

If JSDOMNodeJSEnv is used, crypt npm module is not loaded (require("crypto")), so using UUID.randomUUID() in Scala.js will throw java.lang.UnsupportedOperationException.

build.sbt:

Test / jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()

An example exception:

java.security.SecureRandom is not supported on this platform because it provides neither `crypto.getRandomValues` nor Node.js' "crypto" module.

java.lang.UnsupportedOperationException: java.security.SecureRandom is not supported on this platform because it provides neither `crypto.getRandomValues` nor Node.js' "crypto" module.
  at java.security.SecureRandom$.notSupported(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:25407:51)
  at java.security.SecureRandom$.getRandomValuesFun$lzycompute(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:25401:128)
  at java.security.SecureRandom$.java$security$SecureRandom$$getRandomValuesFun(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:25437:62)
  at java.security.SecureRandom.<init>(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:37078:94)
  at java.util.UUID$.csprng$lzycompute(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:26996:32)
  at java.util.UUID$.csprng(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:27002:70)
  at java.util.UUID$.randomUUID(file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:27032:3)

Related:

A workaround is trying to avoid using UUID.newUUID() in Scala.js during testing with NodeJS and DOM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions