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

Allow parallel execution of async graph.build #887

Closed
corporateuser opened this issue Oct 18, 2023 · 1 comment · Fixed by SAP/ui5-project#669
Closed

Allow parallel execution of async graph.build #887

corporateuser opened this issue Oct 18, 2023 · 1 comment · Fixed by SAP/ui5-project#669
Assignees
Labels
bug Something isn't working module/ui5-project Related to the UI5 Project module

Comments

@corporateuser
Copy link

Expected Behavior

I should be able to run multiple graph.build in parallel with async functions. This is extremely useful for CAP projects where we have multiple independent UI5 applications.

Current Behavior

Due to several places with global variables we're having conflicts between different executions, e.g. for logs in node_modules/@ui5/project/lib/build/ProjectBuilder.js line 4 or minify task worker pool node_modules/@ui5/builder/lib/processors/minifier.js line 17

Steps to Reproduce the Issue

  1. Create several independent fiori/ui5 applications
  2. Try to do parallel build with:
ui5Apps = ['app/app1/ui5.yaml','...','app/app30/ui5.yaml'];
await Promise.all(
  ui5Apps.map((ui) => buildUi(ui))
);

Where build is

async function buildUi(ui) {
  const folderName = path.dirname(ui);
  let graph = await graphFromPackageDependencies({
    cwd: folderName,
    rootConfigPath: `./ui5.yaml`,
  });
  await graph.build({
    destPath: `app/dist/resources`,
    cleanDest: false,
    includedTasks: ['generateCachebusterInfo'],
    excludedTasks: ['replaceVersion'],
  });
}

Context

  • UI5 Module Version (output of ui5 --version when using the CLI): 3.6.0
  • Node.js Version: v20.8.0
  • yarn Version: 1.22.19
  • OS/Platform: MacOS
  • Browser (if relevant): not relevant
  • Other information regarding your environment (optional): nothing

Log Output / Stack Trace

Error: loggers/Build#endProjectBuild: Unknown project <project_name>
    at Build.endProjectBuild (file:///.../node_modules/@ui5/logger/lib/loggers/Build.js:54:10)
    at ProjectBuilder.build (file:///.../node_modules/@ui5/project/lib/build/ProjectBuilder.js:245:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ProjectGraph.build (file:///.../node_modules/@ui5/project/lib/graph/ProjectGraph.js:572:3)
    at async buildUi (file:///.../build-ui.mjs:194:3)
@corporateuser corporateuser added bug Something isn't working needs triage Needs to be investigated and confirmed as a valid issue that is not a duplicate labels Oct 18, 2023
@d3xter666 d3xter666 self-assigned this Oct 18, 2023
@d3xter666 d3xter666 added module/ui5-project Related to the UI5 Project module and removed needs triage Needs to be investigated and confirmed as a valid issue that is not a duplicate labels Oct 19, 2023
d3xter666 added a commit to SAP/ui5-project that referenced this issue Oct 20, 2023
Fixes: SAP/ui5-tooling#887

ProjectBuilder was using a singleton of the logger module. Basically,
the logger was constructed only once, during module evaluation, but used
throughout the whole module.
The tricky part is that the `ProjectBuilder`'s logger has this
`setProjects()` method that acts as an allow list of the projects being
built. As the logger used to be a singleton within this module/class and
the async behaviour of the whole module, calling `setProject()` was
polluting the internal `projects` property.

With this fix, every `ProjectBuilder` instance has its own`BuildLogger`
instance that solves the issue.
@d3xter666
Copy link
Contributor

Hey @corporateuser,

Thanks for reporting this issue!
The fix si ready in @ui5/project@3.7.3 and @ui5/cli@3.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module/ui5-project Related to the UI5 Project module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants