Skip to content

JavaScript string-reverse example fails #301

@catamorphism

Description

@catamorphism

I'm trying to work through the "Creating Components" > "JavaScript" section. Under the Exporting WIT Interfaces with jco section, I'm finding that the string-reverse example isn't working.

Steps to reproduce:

  1. Created a wit/component.wit file as instructed, except that I had to edit it to fix a syntax error (missing semicolon after the package declaration).
  2. Created a string-reverse.mjs file as instructed.
  3. Ran the npx jco componentize command as instructed; note that I had to change --disable all to --disable=all.
  4. Ran the npx jco transpile command as instructed.
  5. Added a package.json file that looks like:
  •  {
     "name": "string-reverse",
     "description": "Simple codebase for compiling a string reversing interface to WebAssembly with jco",
     "type": "module"
     }
    
    (This step isn't in the docs, but if it's omitted, I get an error about modules when running the next step.)
  1. Saved the next bit of code (beginning with import { reverse } to run.js.
  2. node run.js

Result:

wasm://wasm/02a47f8a:1


RuntimeError: unreachable
    at wasm://wasm/02a47f8a:wasm-function[3]:0x971c
    at wasm://wasm/02a47f8a:wasm-function[4342]:0x1b4560
    at example:string-reverse/reverse@0.1.0#reverse-string (wasm://wasm/02a47f8a:wasm-function[13444]:0x81449e)
    at Object.reverseString (file:///home/tjc/wasm-scratch/js-example/string-reverse-2/dist/transpiled/string-reverse.js:668:15)
    at file:///home/tjc/wasm-scratch/js-example/string-reverse-2/run.js:4:26

Node.js v22.18.0

I'll keep trying to debug this, but I was hoping someone else might be able to try reproducing it so I know whether it's some quirk of my setup.

npx jco --version prints "1.13.2".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions