Skip to content

Fix docs gulp race condition with dsl target directories#22292

Merged
gnodet merged 1 commit intomainfrom
fix/docs-gulp-race-condition
Mar 27, 2026
Merged

Fix docs gulp race condition with dsl target directories#22292
gnodet merged 1 commit intomainfrom
fix/docs-gulp-race-condition

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 27, 2026

Summary

The gulpfile.js glob pattern ../dsl/**/src/main/docs/... uses ** which recurses into target/ directories created by concurrent Maven builds. When a test process deletes target/surefire while gulp is scanning, it causes an ENOENT error that fails the docs build:

Error: ENOENT: no such file or directory, scandir '.../dsl/camel-kamelet-main/target/surefire'

This is a race condition that occurs intermittently when docs and dsl modules build in parallel (e.g., with mvnd).

PR #21996 added { ignore: ['**/target/**'] } to gulp.src() calls, but the ignore option filters after directory scanning has begun — the ENOENT can still occur during the scandir call itself, before the ignore filter runs. This PR fixes the root cause by replacing the ** glob with explicit depth patterns that structurally prevent entering target/ directories.

Fix: Replace ** with explicit depth patterns using !(target) extglob:

  • dsl/src/main/docs/... for the root-level dsl.adoc
  • dsl/{*,*/!(target)}/src/main/docs/... for depth 1–2 subdirectories

Note: This race condition is primarily observable during local development with mvnd, where docs and dsl modules build in parallel. In CI, regen.sh uses ./mvnw (sequential), so the race is much less likely. This is a preventive improvement, consistent with the approach in #21996.

Validation

Verified that old and new glob patterns produce identical file lists (all 11 dsl doc files):

Old: ../dsl/**/src/main/docs/*.adoc  (with ignore: ['**/target/**'])
New: ../dsl/src/main/docs/*.adoc  +  ../dsl/{*,*/!(target)}/src/main/docs/*.adoc

Both match exactly:
  dsl/src/main/docs/dsl.adoc
  dsl/camel-cli-connector/src/main/docs/cli-connector.adoc
  dsl/camel-cli-debug/src/main/docs/cli-debug.adoc
  dsl/camel-dsl-modeline/src/main/docs/dsl-modeline.adoc
  dsl/camel-java-joor-dsl/src/main/docs/java-joor-dsl.adoc
  dsl/camel-kamelet-main-support/src/main/docs/kamelet-main-support.adoc
  dsl/camel-kamelet-main/src/main/docs/kamelet-main.adoc
  dsl/camel-xml-io-dsl/src/main/docs/java-xml-io-dsl.adoc
  dsl/camel-xml-jaxb-dsl/src/main/docs/java-xml-jaxb-dsl.adoc
  dsl/camel-yaml-dsl/camel-yaml-dsl-validator-maven-plugin/src/main/docs/camel-yaml-dsl-validator-maven-plugin.adoc
  dsl/camel-yaml-dsl/camel-yaml-dsl/src/main/docs/yaml-dsl.adoc

Full gulp build completes successfully with all 71 "others" doc files and all DSL entries present in the generated nav.adoc.

Test plan

  • Verified old and new glob patterns match exactly the same 11 dsl doc files (using npx glob@11)
  • Ran gulp build — completes with no errors, all 71 "others" pages generated
  • Checked generated others/nav.adoc — all DSL entries present (dsl, cli-connector, cli-debug, dsl-modeline, java-joor-dsl, kamelet-main, kamelet-main-support, java-xml-io-dsl, java-xml-jaxb-dsl, yaml-dsl, camel-yaml-dsl-validator-maven-plugin)
  • CI green on this PR

@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions bot added the docs label Mar 27, 2026
@apupier
Copy link
Contributor

apupier commented Mar 27, 2026

For the test plan to validate the issue, we also need to check that the website doc is still genrated will all the correct content

@github-actions
Copy link
Contributor

🧪 CI tested the following changed modules:

  • docs

@gnodet
Copy link
Contributor Author

gnodet commented Mar 27, 2026

Good point. I've verified that the website docs are still generated with all correct content:

Glob pattern equivalence: Using npx glob@11, confirmed both old (../dsl/**/src/main/docs/*.adoc with ignore: ['**/target/**']) and new (../dsl/src/main/docs/*.adoc + ../dsl/{*,*/!(target)}/src/main/docs/*.adoc) patterns match exactly the same 11 files — no files gained, none lost.

Full gulp build: Ran gulp end-to-end — completed successfully with all 71 "others" pages generated and all DSL entries present in the generated nav.adoc (dsl, cli-connector, cli-debug, dsl-modeline, java-joor-dsl, kamelet-main, kamelet-main-support, java-xml-io-dsl, java-xml-jaxb-dsl, yaml-dsl, camel-yaml-dsl-validator-maven-plugin).

CI: Green on this PR.

Regarding build links: this race condition is primarily observable during local development with mvnd (where docs and dsl modules build in parallel). In CI, regen.sh uses ./mvnw sequentially, making the race much less likely. No CI builds were found with this specific ENOENT error. This is a preventive improvement, consistent with PR #21996 which was also described as a "preventive change, not a fix for a specific observed failure."

I've updated the PR description with the full validation details.

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet requested review from apupier and oscerd March 27, 2026 09:35
gnodet added a commit that referenced this pull request Mar 27, 2026
The ENOENT race condition fix for the docs gulp build belongs in
PR #22292 (fix/docs-gulp-race-condition), not in this PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the fix/docs-gulp-race-condition branch from 7ebb835 to 5539141 Compare March 27, 2026 12:22
The gulpfile.js glob pattern '../dsl/**/src/main/docs/...' uses **
which recurses into target/ directories created by concurrent builds.
When a test process deletes target/surefire while gulp is scanning,
it causes an ENOENT error that fails the docs build.

Fix by replacing ** with explicit depth patterns:
- dsl/src/main/docs/... for depth-0 (dsl.adoc)
- dsl/{*,*/!(target)}/src/main/docs/... for depth 1-2, excluding
  target directories via extglob

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the fix/docs-gulp-race-condition branch from 5539141 to 3ec45dc Compare March 27, 2026 12:40
@gnodet
Copy link
Contributor Author

gnodet commented Mar 27, 2026

Note: the second commit (3ec45dc) adds a resilientSrc wrapper around gulp.src() that gracefully handles ENOENT errors from ephemeral directories (e.g. .camel-jbang/work created/deleted by tests running in parallel). Instead of failing the build, it logs a warning and continues. This is a defense-in-depth measure — the first commit prevents scanning target/, but other transient directories could still cause the same race condition during parallel builds.

It also adds .camel-jbang/** to the ignore patterns and logs the number of symlinked files per destination for easier debugging.

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet force-pushed the fix/docs-gulp-race-condition branch from 3ec45dc to c9ac60d Compare March 27, 2026 14:17
@gnodet
Copy link
Contributor Author

gnodet commented Mar 27, 2026

Dropped the second commit (resilient ENOENT handling). The .camel-jbang/work directory issue will be handled separately by fixing the tests to not create ephemeral directories in the source tree where gulp scans.

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet merged commit 24314bc into main Mar 27, 2026
5 checks passed
@gnodet gnodet deleted the fix/docs-gulp-race-condition branch March 27, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants