Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host.arrayBufferToBase64 panics #119

Closed
mhmd-azeez opened this issue Jan 12, 2025 · 1 comment · Fixed by #122
Closed

Host.arrayBufferToBase64 panics #119

mhmd-azeez opened this issue Jan 12, 2025 · 1 comment · Fixed by #122

Comments

@mhmd-azeez
Copy link
Contributor

Repro:

export function greet() {
  const base64String = "SGVsbG8g8J+MjSBXb3JsZCHwn4yN";

  console.log('decoding string:', base64String);

  const decodedBuffer = Host.base64ToArrayBuffer(base64String);
  const decodedString = new TextDecoder().decode(decodedBuffer);

  console.log('decoded string:', decodedString);

  const encodedBuffer = Host.arrayBufferToBase64(decodedBuffer);
  
  console.log('encoded string:', encodedBuffer);

  Host.outputString(`Hello, ${Host.inputString()}`)
}

v1.3.3:

mo@mo-dylibso:/mnt/d/x/extism/ts_plugin$ extism-js --version
extism-js 1.3.3
mo@mo-dylibso:/mnt/d/x/extism/ts_plugin$ npm run build && npm run test

> [email protected] build
> tsc --noEmit && node esbuild.js && extism-js dist/index.js -i src/index.d.ts -o dist/plugin.wasm


> [email protected] test
> extism call dist/plugin.wasm greet --input 'Mo' --wasi --log-level debug

2025/01/12 19:57:17 Calling function : greet
2025/01/12 19:57:17 decoding string: SGVsbG8g8J+MjSBXb3JsZCHwn4yN
2025/01/12 19:57:17 decoded string: Hello 🌍 World!🌍
Error: wasm error: unreachable
wasm stack trace:
        .$1363(i32,i32,i32,i32,i32)
        .$1496(i32,i32)
        .$1487(i32,i32,i32)
        .$1513(i32)
        .$217(i32,i32) i32
        .$1567(i32) i32
        .$1584() i32
returned non-zero exit code: 1

v1.2.0:

mo@mo-dylibso:/mnt/d/x/extism/ts_plugin$ extism-js --version
extism-js 1.2.0
mo@mo-dylibso:/mnt/d/x/extism/ts_plugin$ npm run build && npm run test

> [email protected] build
> tsc --noEmit && node esbuild.js && extism-js dist/index.js -i src/index.d.ts -o dist/plugin.wasm


> [email protected] test
> extism call dist/plugin.wasm greet --input 'Mo' --wasi --log-level debug

2025/01/12 19:59:05 Calling function : greet
2025/01/12 19:59:05 decoding string: SGVsbG8g8J+MjSBXb3JsZCHwn4yN
2025/01/12 19:59:05 decoded string: Hello 🌍 World!🌍
2025/01/12 19:59:05 encoded string: SGVsbG8g8J+MjSBXb3JsZCHwn4yN
Hello, Mo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant