[BUG] Multiple openapi-generator-cli processeses may download jar to corrupt file
See original GitHub issue🐛 Bug Report:
Describe the bug
When multiple node processes execute openapi-generator-cli
, and multiple node processes download the openapi-generator jar
file, it may become corrupt.
Steps to Reproduce
Steps to reproduce the behavior:
- Execute 2 or more node processes that execute
openapi-generator-cli
- If they both detect that the openapi-generator jar should be downloaded, both will do so simultaneously, to the same location.
- Both processes write to the same file, and it may become corrupt.
Expected behavior
There should not be any file corruption, and also not any errors.
You may use a file lock, or download it to a temporary location and move it atomically to the correct location after downloading.
Screenshots
Excerpt of openapi-generator-cli downloading the jar file.
Download 5.0.0-beta2 ...
(node:18698) UnhandledPromiseRejectionWarning: Error: Error: Invalid or corrupt jarfile /home/hidde.wieringa/Projects/api/node_modules/@openapitools/openapi-generator-cli/ve
rsions/5.0.0-beta2.jar
at /home/hidde.wieringa/Projects/api/node_modules/@openapitools/openapi-generator-cli/main.js:613:32
at ChildProcess.exithandler (child_process.js:315:5)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Socket.<anonymous> (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Pipe.<anonymous> (net.js:673:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18698) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by
rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18698) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js pro
cess with a non-zero exit code.
Downloaded 5.0.0-beta2
[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=false
Operation System (please complete the following information):
- Debian 10
Package System (please complete the following information):
1.0.18-5.0.0-beta2
- Yarn workspaces is in use
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
CLI Installation - OpenAPI Generator
This page documents how to install the CLI artifact. Installing OpenAPI Generator's CLI tool allows users to generate all available generators ...
Read more >Fix list for IBM Business Automation Workflow
APAR/Known Issue Security Title
JR65073 X MULTIPLE SECURITY VULNERABILITIES IN SWAGGER UI
DT143805 FIX FOR JR64316 IS INCOMPLETE
DT143824 PDW PRUNE FAILS WITH A SQL EXCEPTION...
Read more >Compiler error "archive for required library could not be read"
What I would like to know is why my IDE is displaying Java Build Problems that read "Archive required for library library/path/somejar.jar cannot...
Read more >Release Notes — Axon Ivy Platform 9.2 documentation
startInFrameRef generates corrupt urls + XIVY-3979 Bug Can't see sources ... pmv file format + XIVY-4023 Bug External Browser opens many tabs in...
Read more >General Error Messages | InterSystems Error Reference
Two error codes, 83 and 5001, are provided to enable you to generate your own custom ... 404, No version information found in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kay-schecker
I would like to request this issue re-opened. As mentioned in the issue description, Yarn workspaces are in use. That means that a single
node_modules
folder is used for (many) workspaces. The workspaces contain the Node code and configuration (includingopenapitools.json
for many workspaces).This means that the solution for multiple
generators
inopenapitools.json
will not work, because the workspaces each have their ownopenapitools.json
file.We use gulp to call tasks in workspaces in parallel, because Yarn workspaces are fully indepentent, including the generation of their code clients with
openapi-generator-cli
.Approximate directory layout:
The workaround of calling
openapi-generator-cli version-manager set 5.0.0-beta2
will work as a workaround, but requires that the root project knows the version ofopenapi-generator
of each of the workspaces. This is not a good thing, because the workspaces should be independent.My request remains: the downloading of the binary concurrently should be done correctly, by either locking the file in the filesystem, or by downloading it to a temporary directory and then moving it atomically to the correct location.
🎉 This PR is included in version 2.2.0 🎉
The release is available on:
Your semantic-release bot 📦🚀