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

Use UndefOr for Node.js file Flags not supported on windows #3127

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

armanbilge
Copy link
Member

@armanbilge armanbilge commented Feb 5, 2023

Thanks to @sherpal for reporting! Update: they confirmed the fix works ✅

Stack trace:

<ref *2> $c_Lorg_scalajs_linker_runtime_UndefinedBehaviorError [org.scalajs.linker.runtime.UndefinedBehaviorError]: java.lang.ClassCastException: undefined cannot be cast to java.lang.Double
    at $throwClassCastException (file:///C:/Users/antoi/IdeaProjects/Ejoti/server/target/scala-3.2.0/server-fastopt/main.js:55:9)
    at $uD (file:///C:/Users/antoi/IdeaProjects/Ejoti/server/target/scala-3.2.0/server-fastopt/main.js:532:73)
    at $c_Lfs2_io_file_Flag$ (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/js/src/main/scala/fs2/io/file/Flag.scala:43:19)
    at $m_Lfs2_io_file_Flag$ (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/js/src/main/scala/fs2/io/file/Flag.scala:31:8)
    at $c_Lfs2_io_file_Flags$ (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/shared/src/main/scala/fs2/io/file/Flags.scala:42:20)
      at $m_Lfs2_io_file_Flag$ (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/js/src/main/scala/fs2/io/file/Flag.scala:31:8)
      at $c_Lfs2_io_file_Flags$ (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/shared/src/main/scala/fs2/io/file/Flags.scala:42:20)      at $m_Lfs2_io_file_Flags$ (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/shared/src/main/scala/fs2/io/file/Flags.scala:38:8)
      at $c_Lfs2_io_file_FilesCompanionPlatform$AsyncFiles.readUtf8__Lfs2_io_file_Path__Lfs2_Stream (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/shared/src/main/scala/fs2/io/file/Files.scala:264:71)
      at $c_Lfs2_io_file_FilesCompanionPlatform$AsyncFiles.readUtf8Lines__Lfs2_io_file_Path__Lfs2_Stream (https://raw.githubusercontent.com/typelevel/fs2/v3.5.0/io/shared/src/main/scala/fs2/io/file/Files.scala:436:15)
      at $c_Lserver_reproducer$package$.run__V (C:\Users\antoi\IdeaProjects\Ejoti\server\src\main\scala\server\reproducer.scala:13:21)
      at $s_Lserver_run__main__AT__V (C:\Users\antoi\IdeaProjects\Ejoti\server\src\main\scala\server\reproducer.scala:6:1) {
    jl_Throwable__f_s: 'undefined cannot be cast to java.lang.Double',
    jl_Throwable__f_e: null,
    jl_Throwable__f_enableSuppression: false,
    jl_Throwable__f_writableStackTrace: true,
    jl_Throwable__f_jsErrorForStackTrace: [Circular *1],
    jl_Throwable__f_stackTrace: null,
    jl_Throwable__f_suppressed: null  },
  jl_Throwable__f_enableSuppression: false,  jl_Throwable__f_writableStackTrace: true,
  jl_Throwable__f_jsErrorForStackTrace: [Circular *2],
  jl_Throwable__f_stackTrace: null,
  jl_Throwable__f_suppressed: null
}

I considered using a lazy val to defer the exception (instead of at init), but it seems that the JDK offers equivalent flags on all platforms (I assume by no-opping). So we just fallback to 0 bits set. Anyway, this saves users from having to condition use of this flag per-OS.

@armanbilge armanbilge changed the title Use UndefOr for JS Flags not supported on windows Use UndefOr for Node.js file Flags not supported on windows Feb 5, 2023
@mpilquist mpilquist merged commit 97dbf80 into typelevel:main Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants