Template incorrectly references 2.x versions of @asyncapi/parser instead of 1.x
ivankahl opened this issue ยท 4 comments
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 if2.x
isn't released yet?
How to Reproduce
Steps to reproduce the issue. Attach all resources that can help us understand the issue:
- Generate a project using the template:
ag asyncapi.yaml @asyncapi/nodejs-ws-template -p server=dev -o ws-server
- Install NPM packages:
npm install
- Run the application:
npm run start
Expected behaviour
The application should start successfully and let me connect to the WebSocket paths.
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.
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
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.
๐ This issue has been resolved in version 0.9.32 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐