Skip to content

[BUG] asyncapi cli race condition crash #2293

Closed

Description

@konekohana

Describe the bug.

Asyncapi cli 6.0.0 seems to sometimes crash when invoked many times in parallel in docker. It crashes with the following error:

Error: EEXIST: file already exists, mkdir 
'/usr/local/lib/node_modules/@asyncapi/cli/lib/utils/logs'
Code: EEXIST

which suggests that the crash might be caused by the following in logger.ts:

const logDir: string = path.join(__dirname, config.has('log.dir') ? config.get('log.dir') : 'logs');
if (!fs.existsSync(logDir)) {
  fs.mkdirSync(logDir);
}

This is extremely unlikely to cause issues on a normal system because the folder gets created once and then never again but that's not the case in a fresh docker container. It's still very rare there, I've seen the crash just once myself and once on a colleague's machine, but it can happen.

Can't contribute a PR sadly because I'm not a TypeScript developer.

Expected behavior

asyncapi not crashing with EEXIST: file already exists, mkdir '/usr/local/lib/node_modules/@asyncapi/cli/lib/utils/logs'

Screenshots

Error log from one of the crashes. Happened as part of cargo build that runs asyncapi generate internally.

109.4 error: failed to run custom build command for `<redacted>`
109.4 
109.4 Caused by:
109.4   process didn't exit successfully: `<redacted>` (exit status: 1)
109.4   --- stdout
109.4   cargo::rerun-if-changed=<redacted>
109.4 
109.4   --- stderr
109.4   Pre-build failed generating API payloads for <redacted> error: WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
109.4   WARNING: See https://github.com/node-config/node-config/wiki/Strict-Mode
109.4   WARNING: No configurations found in configuration directory:<redacted>
109.4   WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
109.4       Error: EEXIST: file already exists, mkdir 
109.4       '/usr/local/lib/node_modules/@asyncapi/cli/lib/utils/logs'
109.4       Code: EEXIST
109.4 
109.4 warning: build failed, waiting for other jobs to finish...

How to Reproduce

Wasn't able to reliably reproduce with asyncapi cli outside of our docker image. The following shows a similar error though:

export NPM_CONFIG_PREFIX="$(mktemp -d)"
trap 'rm -rf "$NPM_CONFIG_PREFIX"' EXIT

npm install -g @asyncapi/[email protected]
cd "$(npm root -g)/@asyncapi/cli"

export SUPPRESS_NO_CONFIG_WARNING=true
for round in {1..100}; do
    rm -rf lib/utils/logs
    for i in $(seq 1 8); do
        node -e "require('./lib/utils/logger')" &
    done
    wait
done

🖥️ Device Information [optional]

No response

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

Activity

  1. added
    bug
    on Sep 3, 2026
  2. github-actions commented on Sep 3, 2026

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

  3. devxdh commented on Sep 3, 2026

    @devxdh

    @konekohana I'm on it. Thank you for notifying the issue.

  4. devxdh commented on Oct 7, 2026

    @devxdh

    @AayushSaini101 Please have a look.

  5. added a commit that references this issue on Oct 20, 2026
    e0e3d97
  6. frederikb commented on Oct 28, 2026

    @frederikb

    Still happens on 6.2.2 when we run asyncapi validate in parallel in CI after a fresh install. #2324 and #2327 both fix it. Could a maintainer merge one of them?

  7. konekohana commented on Oct 28, 2026

    @konekohana
    Author

    @frederikb until this gets merged, a quick and dirty workaround is to create the folder ahead of time to make sure the buggy condition never evaluates true:

    mkdir -p "$(npm root -g)/@asyncapi/cli/lib/utils/logs"
    
  8. moved this from To Triage to Done in CLI - Kanbanon Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions