Skip to content

[wasm] Mark server APIs unsupported instead of panicking at runtime #17

Description

@yorkin-bot

Summary

At main@c545db2 (module version 0.8.0), the README correctly says that Mocket supports the JS and native backends. However, the package configuration still selects mocket.wasm.mbt and serve.mbt for wasm/wasm-gc, so server code using Mocket::listen type-checks successfully for those targets and then traps at runtime.

Relevant code:

Reproduction

fn main {
  @mocket.new().listen("127.0.0.1:49401")
}

With an executable package that declares Wasm support:

moon check <package> --target wasm
# succeeds

moon check <package> --target wasm-gc
# succeeds

moon run <package> --target wasm
# RuntimeError: unreachable
#   at @oboard/mocket.listen_ffi
#   at @oboard/mocket.Mocket::listen

Expected behavior

Unsupported server targets should be rejected at build/check time rather than exposing public APIs that always panic.

The direct fix is to declare the package's actual backend support at the top level of moon.pkg:

supported_targets = "js+native"

This makes moon check/moon build reject wasm and wasm-gc consumers at the package boundary, matching the README and avoiding runtime-only panic stubs. If a functional Wasm/WASI server backend is implemented later, the target set can be expanded then.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions