Skip to content

moleculeFlow with immediate recomposition mode errors on NodeJS #441

@kevincianfarini

Description

@kevincianfarini

I introduced molecule as a way to test some library code which exposes a Composable function. In doing so, I exposed that molecule does not seem to be compatible with NodeJS while running tests. I get the following error:

io.github.kevincianfarini.monarch.StateOfTest.stateOf_starts_with_current_value[js, node] FAILED
    ReferenceError: window is not defined
        at <global>.sendFrame(/home/kevin/code/monarch/compose/build/compileSync/js/test/testDevelopmentExecutable/kotlin/js-ir/runtime/long.kt:27)
        at GatedFrameClock.protoOf.set_isRunning_m21k59(/Users/runner/work/molecule/molecule/molecule-runtime/src/commonMain/kotlin/app/cash/molecule/GatedFrameClock.kt:45)
        at slambda.protoOf.doResume_5yljmg(/Users/runner/work/molecule/molecule/molecule-runtime/src/commonMain/kotlin/app/cash/molecule/molecule.kt:80)
        at slambda.protoOf.invoke_d9fzmj(kotlin/molecule-molecule-runtime.js:459)
        at <global>.l(kotlin/molecule-molecule-runtime.js:543)
        at <global>.startUndispatchedOrReturn(/home/kevin/code/monarch/compose/build/compileSync/js/test/testDevelopmentExecutable/kotlin/js-ir/src/kotlin/coroutines_13/IntrinsicsJs.kt:99)
        at <global>.coroutineScope(/mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/CoroutineScope.kt:261)
        at slambda.protoOf.doResume_5yljmg(/Users/runner/work/molecule/molecule/molecule-runtime/src/commonMain/kotlin/app/cash/molecule/molecule.kt:61)
        at slambda.protoOf.invoke_ilgcjr(kotlin/molecule-molecule-runtime.js:556)
        at SafeFlow.block(kotlin/molecule-molecule-runtime.js:603)
        at SafeFlow.protoOf.collectSafely_blptet(/mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/flow/Builders.kt:57)
        at 3.protoOf.doResume_5yljmg(/mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/flow/Flow.kt:226)
        at SafeFlow.protoOf.collect_aksokr(kotlin/kotlinx-coroutines-core.js:10079)

Is this expected behavior? I see that this repository declares JS targets that run tests on the browser, but should that preclude it from running on NodeJS? I've tried using both the Jetbrains Compose plugin while declaring molecule's runtime as implementation, and using the molecule plugin directly. Both produce the same results.

Here's a public reproducer sample: kevincianfarini/monarch@b1566e6

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