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

Various issues with examples #169

Closed
maucaro opened this issue Apr 5, 2022 · 9 comments
Closed

Various issues with examples #169

maucaro opened this issue Apr 5, 2022 · 9 comments

Comments

@maucaro
Copy link
Contributor

maucaro commented Apr 5, 2022

Have the examples been tested recently and are they supposed to work?
I have not been able to get any to work:

With nodejs-ts-app-multi-entrypoint I am getting:

nodejs-ts-app-multi-entrypoint@1.0.0 start
ts-node app.ts

Running multi entrypoint demo suite
Iterations: 100000 iterations of 10 inputs for 1000000 total evals per entrypoint
default entrypoint: 10.013s
ERROR: entrypoint example/one is not valid in this instance

With nodejs-ts-app I am getting an empty result:

nodejs-app@1.0.0 start
ts-node app.ts "{"message": "world"}"

[]

With nodejs-app I also get an empty result.

I am running Node.js v14.17.5 on Windows 10.

@srenatus
Copy link
Contributor

srenatus commented Apr 5, 2022

Yes, some of them should be tested continuously -- concretely: https://github.com/open-policy-agent/npm-opa-wasm/tree/main/examples/nodejs-ts-app

Can you check if the build process has run correctly for the example, like done in the script?

https://github.com/open-policy-agent/npm-opa-wasm/blob/main/e2e.sh#L9-L10

@maucaro
Copy link
Contributor Author

maucaro commented Apr 5, 2022

Yes, it sure seems to:
npm run build

nodejs-app@1.0.0 build
opa build -t wasm -e 'example/hello' ./example.rego && tar xzf ./bundle.tar.gz /policy.wasm

tar: Removing leading '/' from member names

(in case opa version helps):
opa version
Version: 0.39.0
Build Commit: cc965f6
Build Timestamp: 2022-03-31T12:34:56Z
Build Hostname: 5aba1d393f31
Go Version: go1.18
Platform: windows/amd64
WebAssembly: available

@maucaro
Copy link
Contributor Author

maucaro commented Apr 5, 2022

Interesting, the issue seems to be with my local opa build. I used 'example.wasm' that was pre-built here: and it worked as expected.

Yet, there are no errors from the opa build command. Any ideas?

@srenatus
Copy link
Contributor

srenatus commented Apr 5, 2022

Hrrm this could be related to argument parsing again. Perhaps the entrypoint got mangled by some powershell command, as in open-policy-agent/opa#3953.

@srenatus
Copy link
Contributor

srenatus commented Apr 5, 2022

You could fiddle with the lib to inspect the entrypoints, see https://github.com/open-policy-agent/npm-opa-wasm/blob/main/src/opa.js#L290. I'm afraid there's no better tooling available right now.

@maucaro
Copy link
Contributor Author

maucaro commented Apr 5, 2022

Thanks for the prompt answers. I will give it a try. Feel free to close as the issue is not with the examples themselves.

@srenatus srenatus closed this as completed Apr 5, 2022
@maucaro
Copy link
Contributor Author

maucaro commented Apr 5, 2022

Just tested the opa build command with double quotes and it does work. Perhaps a note for Windows (PowerShell) users would be in order.

@srenatus
Copy link
Contributor

srenatus commented Apr 5, 2022

Agreed! Would pushing a PR for that against OPA be something you'd be up to? 😃

@maucaro
Copy link
Contributor Author

maucaro commented Apr 6, 2022

I submitted a PR and then modified it 3 times to try to make the linter happy but am now at a loss as to how to make it pass. Feel free to suggest edits or take the suggestion and apply it directly, tweaking it if needed. It should also be applied to the other 2 examples. Thanks!

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

2 participants