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

Template incorrectly references 2.x versions of @asyncapi/parser instead of 1.x #271

Closed
ivankahl opened this issue Mar 30, 2023 · 4 comments · Fixed by #272
Closed

Template incorrectly references 2.x versions of @asyncapi/parser instead of 1.x #271

ivankahl opened this issue Mar 30, 2023 · 4 comments · Fixed by #272
Labels
bug Something isn't working released

Comments

@ivankahl
Copy link
Contributor

ivankahl commented Mar 30, 2023

Describe the bug

When creating a new project using this template, the @asyncapi/parser version is "^2.0.0-next-major.15". It appears that there are breaking changes in this version when coming from 1.x. Because of these changes, the following errors is thrown when trying to run the generated application out-the-box (after running npm install):

(node:10540) UnhandledPromiseRejectionWarning: TypeError: parse is not a function
    at Object.module.exports.init (D:\Code\AsyncApiFoodDelivery\ws-server\src\lib\asyncapi.js:23:20)
    at start (D:\Code\AsyncApiFoodDelivery\ws-server\src\api\index.js:9:18)
    at Object.<anonymous> (D:\Code\AsyncApiFoodDelivery\ws-server\src\api\index.js:27:1)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10540) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:10540) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 

After some testing, I noticed that the parse method is present in 1.x versions of the @asyncapi/parser package. When updating my package.json file to reference "^1.18.1" the application works.

We can fix this by either:

  • Updating the package.json file in the template to reference "^1.18.1" OR
  • Rewrite the template to be compatible with the 2.x version of the @asyncapi/parser. Will this be a big change? Should we do this if 2.x isn't released yet?

How to Reproduce

Steps to reproduce the issue. Attach all resources that can help us understand the issue:

  1. Generate a project using the template: ag asyncapi.yaml @asyncapi/nodejs-ws-template -p server=dev -o ws-server
  2. Install NPM packages: npm install
  3. Run the application: npm run start

Expected behaviour

The application should start successfully and let me connect to the WebSocket paths.

@ivankahl ivankahl added the bug Something isn't working label Mar 30, 2023
@github-actions
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@derberg
Copy link
Member

derberg commented Mar 30, 2023

oh good catch, the bump takes place in https://github.com/asyncapi/nodejs-ws-template/blob/master/template/package.json template files.

better imho is to make sure template works with latest parser as anyway 2.0 will come in few months. And we just need proper tests that prevent bump in case it is breaking generation. We have test that generates code from template, we do not have test that actually starts the generated app

@ivankahl
Copy link
Contributor Author

Makes sense to use the newer API. I've updated the template to use the 2.x @asyncapi/parser library and created a PR linked to this issue.

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.9.32 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants