extism/js-sdk

bug: createPlugin argument seems to have changed

Closed this issue · 4 comments

> const createPlugin = require("@extism/extism")
undefined
> 
> const plugin = await createPlugin(
...     'https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm',
...     { useWasi: true }
... );(node:100) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

Uncaught TypeError: Expected "wasm" key in manifest
    at _populateWasmField (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:343:11)
    at _populateWasmField (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:340:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async intoManifest (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:359:20)
    at async toWasmModuleData (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:365:20)
    at async createPlugin (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:2628:31)
    at async REPL6:1:43

It looks like this interface perhaps changed? If so we need to update the readme and the quickstart, and internal docs https://github.com/extism/js-sdk/blob/main/src/mod.ts#L34

Hm, I couldn't reproduce this:

> const createPlugin = require("@extism/extism")
undefined
> (node:18048) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
const plugin = await createPlugin(
... 'https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm',
... { useWasi: true }
... );
(node:18048) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
undefined

What version of Node & the Extism library are you using? (I tested on Node v21 and v18 against @extism/extism@v1.0.0-rc6.)

I'm on a fresh alpine OS. node v18:

/home/jshost # cat package.json | grep extism
    "@extism/extism": "^1.0.0-rc6"
/home/jshost # node --version
v18.18.2
/home/jshost # node
Welcome to Node.js v18.18.2.
Type ".help" for more information.
> const createPlugin = require("@extism/extism")
undefined
> (node:48) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

> const plugin = await createPlugin(
...  'https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm',
...  { useWasi: true }
... );
Uncaught TypeError: Expected "wasm" key in manifest
    at _populateWasmField (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:343:11)
    at _populateWasmField (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:340:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async intoManifest (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:359:20)
    at async toWasmModuleData (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:365:20)
    at async createPlugin (/home/jshost/node_modules/@extism/extism/dist/cjs/mod.js:2628:31)
    at async REPL6:1:43
> 

reprod on mac os, node v21

Update from chat elseslack: v21.1.0 works, v21.0.0 breaks; v18.19.0 works, v18.18.2 breaks. I suspect something was fixed in Node v21 and backported to v18; I'm looking into this since it affects alpine Docker users with older Node containers.