typelevel / typelevel/cats-effect
TracingPlatform performs undefined behavior in JS that makes it unusable in Wasm
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 576
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 18
Description
https://github.com/typelevel/cats-effect/blob/18fdf52498b00f9908caea77b8c132664656c781/core/js/src/main/scala/cats/effect/tracing/TracingPlatform.scala#L28-L31
These lines attempt to break through Scala.js abstractions. They access JS properties of a Scala.js object. That is undefined behavior.
When linking for WebAssembly, they actually crash, since Scala.js objects really don't have JS properties.
Since Tracing is always called by IO.async, it makes the latter completely unusable with Scala.js-on-Wasm.
There does not appear to be any workaround.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/js/src/main/scala/cats/effect/tracing/TracingPlatform.scala at lines 28-31 and inspect how the JS property access is used by Tracing and IO.async. Reproduce the failure when linking for WebAssembly, then verify that IO.async no longer crashes under Scala.js-on-Wasm and that the tracing behavior remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, scala, wasm
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100