- Notifications
You must be signed in to change notification settings - Fork3
Open
Description
How to reproduce
Given the following files:
// package.json{"type":"module"}
// build.sbtenablePlugins(ScalaJSPlugin)scalaVersion:="3.1.3"libraryDependencies++=Seq( ("org.scala-js"%%%"scalajs-java-securerandom"%"1.0.0").cross(CrossVersion.for3Use2_13))scalaJSLinkerConfig~= { _.withModuleKind(ModuleKind.ESModule) }scalaJSUseMainModuleInitializer:= tru
// src/main/scala/Main.scalaimportjava.security.SecureRandomobjectMain {defmain(args:Array[String]):Unit= { println(randomBytes(16).map(_.toInt).mkString("")) }privatevalsecureRandom=newSecureRandomdefrandomBytes(length:Int):Array[Byte]= {valbuffer=newArray[Byte](length) secureRandom.nextBytes(buffer) buffer } }
Do
sbt fastLinkJSnode target/scala-3.1.3/*-fastopt/main.js
The result will be
file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:2716 throw new $c_jl_UnsupportedOperationException("java.security.SecureRandom is not supported on this platform because it provides neither `crypto.getRandomValues` nor Node.js' \"crypto\" module.") ^<ref *1> java.lang.UnsupportedOperationException: java.security.SecureRandom is not supported on this platform because it provides neither `crypto.getRandomValues` nor Node.js' "crypto" module. at $p_Ljava_security_SecureRandom$__notSupported__E (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:2716:9) at $p_Ljava_security_SecureRandom$__getRandomValuesFun$lzycompute__sjs_js_Function1 (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:2710:128) at $c_Ljava_security_SecureRandom$.java$security$SecureRandom$$getRandomValuesFun__sjs_js_Function1 (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:2746:62) at new $c_Ljava_security_SecureRandom (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:3323:94) at new $c_LMain$ (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:904:33) at $m_LMain$ (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:1024:17) at $s_LMain__main__AT__V (file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:898:3) at file:///home/fiatjaf/comp/misc/target/scala-3.1.3/misc-fastopt/main.js:5965:1 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) { jl_Throwable__f_s: 'java.security.SecureRandom is not supported on this platform because it provides neither `crypto.getRandomValues` nor Node.js\' "crypto" module.', jl_Throwable__f_e: null, jl_Throwable__f_enableSuppression: true, jl_Throwable__f_writableStackTrace: true, jl_Throwable__f_stackTraceStateInternal: [Circular *1], jl_Throwable__f_stackTrace: null, jl_Throwable__f_suppressed: null}Node.js v18.4.0