Title
j

Jason

02/16/2022, 2:13 PM
I'm trying to use @ffmpeg-wasm and it needs webassembly threads support but it seems it's not enabled by default. I tried to enable it by setting
environment: {NODE_OPTIONS: '--experimental-wasm-threads'}
but after adding it the function is just never invoked. it's an api and I am invoking it manually via the sst console. Where am I going wrong? Is this the correct way to enable it? Edit: ah it is trying to invoke, I now see an error
/var/lang/bin/node: --experimental-wasm-threads is not allowed in NODE_OPTIONS
. Is there any way to allow this?
t

thdxr

02/16/2022, 6:08 PM
hm do you think this is a node version issue?
what version do yo uhave
j

Jason

02/16/2022, 6:26 PM
I use the 14.x runtime
On the command line I use node 14.18 and when I run
node --experimental-wasm-threads
I see no error, so not sure why the lambda blocks it
The full definition is
const api = new sst.Api(this, 'Api', {
      routes: {
        'GET /test': {
          handler: 'src/services/queues/consumer.handler',
          layers: [this.ffmpegLayer()],
          environment: {
            NODE_OPTIONS: '--experimental-wasm-threads',
          },
          runtime: 'nodejs14.x',
        },
      },
    });
node only complains when I add the environment variable. when i remove it the library complains because it expects wasm thread support
f

Frank

02/16/2022, 10:43 PM
@Jason are you getting this error running locally (ie.
sst start
) or after u deployed?
j

Jason

02/16/2022, 10:51 PM
@Frank locally, haven't tried deploying
t

thdxr

02/16/2022, 11:04 PM
can you set
enableLiveDev: false
below
handler
and run sst start
j

Jason

02/16/2022, 11:20 PM
@thdxr same error
23:18:51.508
[INFO]
/var/lang/bin/node: --experimental-wasm-threads is not allowed in NODE_OPTIONS
23:18:51.508
[ERROR]
Error: Runtime exited with error: exit status 9 Runtime.ExitError
t

thdxr

02/16/2022, 11:20 PM
So that executed it in aws, not locally which means there must be some versions of node where this isn't supported
j

Jason

02/16/2022, 11:21 PM
is there some way i can specify the 'x' in 14.x?
f

Frank

02/17/2022, 1:09 AM
No, there isn’t.
@Jason can u try running this locally
NODE_OPTIONS=--experimental-wasm-threads node -v
j

Jason

02/17/2022, 9:35 AM
@Frank ok so that's interesting, that doesn't work. I get
node: --experimental-wasm-threads is not allowed in NODE_OPTIONS
. but when I run
node --experimental-wasm-threads
it works fine and actually enables the feature
node --experimental-wasm-threads
Welcome to Node.js v14.18.2.
Type ".help" for more information.
> const check = require("wasm-check")
undefined
> check.feature.threads
true
when I don't pass the flag the feature is disabled
node 
Welcome to Node.js v14.18.2.
Type ".help" for more information.
> const check = require("wasm-check")
undefined
> check.feature.threads
false
>
f

Frank

02/17/2022, 7:57 PM
I see. Do you know if there’s a way to pass in
--experimental-wasm-threads
to Lambda function?
j

Jason

02/17/2022, 10:00 PM
I was hoping you'd know haha. I have no idea, maybe its impossible. I can't find anything online about how to change the start command for a lambda
May just have to wait for them to support node 16, where this is enabled by default.
f

Frank

02/17/2022, 10:52 PM
Haha yeah afaik
NODE_OPTIONS
was the only option