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

Using __dirname to locate polar_wasm_api_bg.wasm causes problems in AWS nodejs lambda #1725

Open
sandborg71 opened this issue Sep 21, 2023 · 0 comments

Comments

@sandborg71
Copy link

When we try to use the oso library from an nodejs AWS lambda (using Serverless Framework) we get a problem with the path to the file polar_wasm_api_bg.wasm. In your library code the path to the polar_wasm_api_bg.wasm file is hardcoded to __dirname (see code snippet below). When the lambda executes this means the same dir as the lambda source and it means that we have to copy this wasm files to all source folders containing lambdas using oso, because of the way lambdas are built and executed. It would be very good if you for example by an optional environment variable or similar could have a bit more flexible way of telling the path to the wasm file. Or maybe there is an even better more standardized way of doing this wasm import in the code.

From your nodejs module node_modules/oso/dist/src/polar_wasm_api.js:

...
const path = require('path').join(__dirname, 'polar_wasm_api_bg.wasm');
const bytes = require('fs').readFileSync(path);

const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
wasm = wasmInstance.exports;
module.exports.__wasm = wasm;
...

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

No branches or pull requests

1 participant