Parallel execution command asyncapi generate got error
Describe the bug
Parallel execution mulitple generate command
for file in "${files[@]}"
do
asyncapi generate fromTemplate $file.json @asyncapi/html-template --param singleFile=true outFilename=$file.html --output ./generate --force-write &
done
wait
Command execution failure Generation Error: ENOENT: no such file or directory, open '/root/generate/asyncapi/css/asyncapi.min.css'
How to Reproduce
some asyncapi json files
for file in "${files[@]}"
do
asyncapi generate fromTemplate $file.json @asyncapi/html-template --param singleFile=true outFilename=$file.html --output ./generate --force-write &
done
wait
Expected behavior
success
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.
Hey there, what is the example $file.json value? /root/generate/asyncapi/css/asyncapi.min.css is a weird path
also, I understand that you tried running it just for one file, and all was fine?
@derberg
Hello. For example, there are five asyncapi files in a directory. file1.json, file2.json, file3.json, file4.json, file5.json.
for file in [file1.json, file2.json, file3.json, file4.json, file5.json]
do
asyncapi generate fromTemplate $file @asyncapi/html-template --param singleFile=true outFilename=$file.html --output ./generate --force-write & # (Adding this symbol ’&‘ allows the loop to continue executing instead of waiting here )
done
wait #(Wait here for all commands to be executed)
If there is only one file under the folder, the execution will not fail.
My guess is that during the execution of the commands, they used a temporary folder with the same name. When one of the
commands deleted the temporary folder and the other command tried to read the temporary folder, this error was issued.
temporary folder is used only if output is not there -> https://github.com/asyncapi/cli/blob/master/src/commands/generate/fromTemplate.ts#L217C11-L217C20
I'm wondering if we might have a bug in html template. This is where the link from the error is coming from -> https://github.com/asyncapi/html-template/blob/master/template/index.html#L11-L16. But could be also issue with removal -> https://github.com/asyncapi/html-template/blob/master/hooks/01_removeNotRelevantParts.js
so the error pops up after first iteration, what is left on disk after error? is anything generated? if yes, then error with removal of css files, if not, then issue with including files inside html (I bet on this one)
Hello, I created a demo that can reproduce this problem: https://github.com/Zacama/asyncapi-generate-test. Those four API documents are the same, copy from https://studio.asyncapi.com/
This is the result of my execution in codespace
If output is a different folder, there is no problem
ok, then it is for sure related to current version of html template.
it runs on old generator rendering engine based on Nunjucks. It forces us to do some hacks for singleFile parameter support. There is basically no conditional files generation, so we basically need to run such hooks after generation -> https://github.com/asyncapi/html-template/blob/master/hooks/01_removeNotRelevantParts.js#L25. So yeah, might happen that script tries to remove a file that was already removed by another run.
once https://github.com/asyncapi/html-template/pull/448 is merged (that introduces react rendering, that is much more flexible) we can easily implement an alternative solution for hooks.
but for now, you will have to generate into unique directory per generation, sorry about that
Okay, thank you~
Hello, I updated the version of the template to 1.0.0 and tried executing it again in the same working directory, and got the following error.
https://github.com/Zacama/asyncapi-generate-test
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
still relevant
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
Hello @AayushSaini101 , @derberg , @Zacama
I hope this message finds you well! This issue interests me , could you please assign it to me!
Thank you!
I would like to work on this issue under the bounty program could you please assign it to me? @thulieblack
Bounty Issue's service comment
Text labels: bounty/2025-Q2, bounty/advanced, bounty/coding
First assignment to regular contributors: 2025-03-21 00:00:00 UTC+12:00
End Of Life after: 2025-04-30 23:59:59 UTC-12:00
@asyncapi/bounty_team
The Bounty Program is not a Mentorship Program. The accepted level of Bounty Program Participants is Middle/Senior.
Regular contributors should explain in meaningful words how they are going to approach the resolution process when expressing a desire to work on this Bounty Issue.
@AayushSaini101 (githubID: 60972989) is an AsyncAPI Maintainer specified in https://github.com/asyncapi/community/blob/master/MAINTAINERS.yaml, so they fall under the first category in the prioritization list.
Bounty Issue's Timeline
| Complexity Level | Assignment Date (by GitHub) | Start Date (by BP Rules) | End Date (by BP Rules) | Draft PR Submission | Final PR Merge Start | Final PR Merge End |
|---|---|---|---|---|---|---|
| Advanced | 2025-02-21 | 2025-04-07 | 2025-06-01 | 2025-04-27 | 2025-05-18 | 2025-06-01 |
Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.
Keep in mind the responsibility for violations of the Timeline.
Assignee: @AayushSaini101 (githubID: 60972989)
Created issue in the board of HTML template: https://github.com/asyncapi/html-template/issues/720#issue-2981418265 to fix the issue
Two approaches for this issue:
- Do changes in the CLI to execute the singleFile operation after the generation of the output [ Done ] ] Secondary choice ]
- Primary Choice for this fix https://github.com/asyncapi/generator/issues/1501 working
This Bounty Issue is in its final stages and is expected to be completed shortly.
@aeworxet issue has been completed and verified also via reference: https://github.com/asyncapi/generator/pull/1515#pullrequestreview-2888032071
Bounty Issue Is Completed 🎉
@AayushSaini101 (githubID: 60972989), please go to the dedicated AsyncAPI Bounty Program 2025-Q2 page on Open Collective and submit an invoice for USD 400.00 (button 'ACTIONS', dropdown option 'Submit expense') with the expense title Bounty cli#814, tag bounty, and full URL of this Bounty Issue in the description.
After submitting the invoice, please post the link to it in this Bounty Issue as a separate comment.
https://opencollective.com/asyncapi/projects/asyncapi-bounty-program/expenses/252257
Closed via: https://github.com/asyncapi/generator/pull/1515#pullrequestreview-2888032071
AayushSaini101
https://opencollective.com/asyncapi/projects/asyncapi-bounty-program/expenses/252257
✅
The invoice https://opencollective.com/asyncapi/projects/asyncapi-bounty-program/expenses/252257 was submitted by @AayushSaini101 (githubID: 60972989), who was the AsyncAPI Bounty Program 2025-Q2 Participant and completed the Bounty Issue cli#814.