typelevel / typelevel/cats-effect

TracingPlatform performs undefined behavior in JS that makes it unusable in Wasm

Open
#4,644 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:beetle: bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.