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

Parallel execution command asyncapi generate got error #814

Open
Zacama opened this issue Sep 19, 2023 · 11 comments
Open

Parallel execution command asyncapi generate got error #814

Zacama opened this issue Sep 19, 2023 · 11 comments
Labels
bug Something isn't working good first issue Good for newcomers stale

Comments

@Zacama
Copy link

Zacama commented Sep 19, 2023

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

@Zacama Zacama added the bug Something isn't working label Sep 19, 2023
@github-actions
Copy link
Contributor

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 Sep 27, 2023

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?

@Zacama
Copy link
Author

Zacama commented Sep 27, 2023

@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.

Copy link
Member

derberg commented Sep 27, 2023

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)

@Zacama
Copy link
Author

Zacama commented Sep 28, 2023

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
image

If output is a different folder, there is no problem
image

Copy link
Member

derberg commented Sep 28, 2023

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 asyncapi/html-template#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

@Zacama
Copy link
Author

Zacama commented Sep 28, 2023

Okay, thank you~

@Zacama Zacama closed this as completed Sep 28, 2023
@Zacama Zacama reopened this Oct 12, 2023
@Zacama
Copy link
Author

Zacama commented Oct 12, 2023

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
image

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity 😴

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 ❤️

@github-actions github-actions bot added the stale label Feb 10, 2024
@github-project-automation github-project-automation bot moved this to Backlog in CLI - Kanban Apr 24, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in CLI - Kanban Jun 9, 2024
Copy link
Collaborator

Amzani commented Jun 10, 2024

still relevant

@Amzani Amzani reopened this Jun 10, 2024
@github-project-automation github-project-automation bot moved this from Done to Ready in CLI - Kanban Jun 10, 2024
@github-actions github-actions bot removed the stale label Jun 11, 2024
@Amzani Amzani added the good first issue Good for newcomers label Jul 5, 2024
Copy link
Contributor

github-actions bot commented Nov 3, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴

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 ❤️

@github-actions github-actions bot added the stale label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers stale
Projects
Status: Backlog
Development

No branches or pull requests

3 participants