fix: comand cannot be run concurrently#1243
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where CLI commands could not be run concurrently by refactoring the application instance from a shared global object to a new instance created per command execution.
- Refactored Application struct to store command metadata instead of maintaining a shared cli.Command instance
- Added a new
instance()method that creates a fresh cli.Command for each execution - Added comprehensive concurrent test coverage to verify the fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| console/application.go | Core fix - replaced shared instance with per-execution instance creation |
| console/application_test.go | Added concurrent test with atomic counters to verify thread safety |
| console/cli_helper_test.go | Fixed test to create isolated application instance per test run |
Comments suppressed due to low confidence (1)
console/application_test.go:172
- This increment operation is not thread-safe. Should use
atomic.AddInt64(&testCommand, 1)to prevent race conditions during concurrent test execution.
testCommand++
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: ddd9626 | Previous: 32ff364 | Ratio |
|---|---|---|---|
Benchmark_DecryptString |
6278 ns/op 2032 B/op 16 allocs/op |
2055 ns/op 2032 B/op 16 allocs/op |
3.05 |
Benchmark_DecryptString - ns/op |
6278 ns/op |
2055 ns/op |
3.05 |
BenchmarkFile_ReadWrite |
317578 ns/op 6258 B/op 99 allocs/op |
169137 ns/op 6258 B/op 99 allocs/op |
1.88 |
BenchmarkFile_ReadWrite - ns/op |
317578 ns/op |
169137 ns/op |
1.88 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.16.x #1243 +/- ##
==========================================
Coverage ? 68.00%
==========================================
Files ? 216
Lines ? 11605
Branches ? 0
==========================================
Hits ? 7892
Misses ? 3333
Partials ? 380 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
em.. local passed, strange, will check it. |
| cliFlags = append(cliFlags, helpFlag) | ||
| } | ||
|
|
||
| cliFlags = append(cliFlags, noANSIFlag) |
|
Please take a look again @goravel/core-developers |
|
Hi @hwbrzzl |
|
@oprudkyi Thanks, amazing, looking forward to merging it. |
* correctly set cc and bcc headers (#1144) * correct the error return from SendMailJob handle (#1147) * fix: [#743] package make command generates correct code (#1151) (#1152) (cherry picked from commit 93dc8a3) * fix: [#749] The path is incorrect when publishing package files (#1157) * chore: optimize assertions for package installation (#1160) * fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162) * fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting * optimize * fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166) * fix: [#738] The Orm Creating event can be triggered when the query with the Model method * fix tests * upgrade: v1.16.1 * fix: [#762] handle panic when using transaction (#1183) * fix: [#762] handle panic when using transaction * v1.16.2 * optimize * fix lint * fix: [#768] facades.DB will panic when migrating a new column (#1185) * fix: [#768] facades.DB will panic when migrating a new column * optimize * optimize * feat: [#770] Add a SelectRaw function for the ORM (#1186) * fix: [#770] Add a SelectRaw function for the ORM * fix: [#770] Add a SelectRaw function for the ORM * fix ci * upgrade: v1.16.3 * fix: comand cannot be run concurrently (#1243) * fix: comand cannot be run concurrently * fix ci * fix ci * optimize * optimize * optimize * optimize * optimize global options * fix ci * upgrade v1.16.4 * optimize * optimize --------- Co-authored-by: krishan kumar <84431594+kkumar-gcc@users.noreply.github.com> Co-authored-by: ALMAS <almas.cc@icloud.com>
* correctly set cc and bcc headers (#1144) * correct the error return from SendMailJob handle (#1147) * fix: [#743] package make command generates correct code (#1151) (#1152) (cherry picked from commit 93dc8a3) * fix: [#749] The path is incorrect when publishing package files (#1157) * chore: optimize assertions for package installation (#1160) * fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162) * fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting * optimize * fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166) * fix: [#738] The Orm Creating event can be triggered when the query with the Model method * fix tests * upgrade: v1.16.1 * fix: [#762] handle panic when using transaction (#1183) * fix: [#762] handle panic when using transaction * v1.16.2 * optimize * fix lint * fix: [#768] facades.DB will panic when migrating a new column (#1185) * fix: [#768] facades.DB will panic when migrating a new column * optimize * optimize * feat: [#770] Add a SelectRaw function for the ORM (#1186) * fix: [#770] Add a SelectRaw function for the ORM * fix: [#770] Add a SelectRaw function for the ORM * fix ci * upgrade: v1.16.3 * fix: comand cannot be run concurrently (#1243) * fix: comand cannot be run concurrently * fix ci * fix ci * optimize * optimize * optimize * optimize * optimize global options * fix ci * upgrade v1.16.4 * fix: [#807] queue.Shutdown doesn't stop the queue as expected (#1252) * fix: [#807] queue.Shutdown doesn't stop the queue as expected * optimize * upgrade: v1.16.5 * fix * Update queue/worker_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * optimize --------- Co-authored-by: krishan kumar <84431594+kkumar-gcc@users.noreply.github.com> Co-authored-by: ALMAS <almas.cc@icloud.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* correctly set cc and bcc headers (#1144) * correct the error return from SendMailJob handle (#1147) * fix: [#743] package make command generates correct code (#1151) (#1152) (cherry picked from commit 93dc8a3) * fix: [#749] The path is incorrect when publishing package files (#1157) * chore: optimize assertions for package installation (#1160) * fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162) * fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting * optimize * fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166) * fix: [#738] The Orm Creating event can be triggered when the query with the Model method * fix tests * upgrade: v1.16.1 * fix: [#762] handle panic when using transaction (#1183) * fix: [#762] handle panic when using transaction * v1.16.2 * optimize * fix lint * fix: [#768] facades.DB will panic when migrating a new column (#1185) * fix: [#768] facades.DB will panic when migrating a new column * optimize * optimize * feat: [#770] Add a SelectRaw function for the ORM (#1186) * fix: [#770] Add a SelectRaw function for the ORM * fix: [#770] Add a SelectRaw function for the ORM * fix ci * upgrade: v1.16.3 * fix: comand cannot be run concurrently (#1243) * fix: comand cannot be run concurrently * fix ci * fix ci * optimize * optimize * optimize * optimize * optimize global options * fix ci * upgrade v1.16.4 * fix: [#807] queue.Shutdown doesn't stop the queue as expected (#1252) * fix: [#807] queue.Shutdown doesn't stop the queue as expected * optimize * upgrade: v1.16.5 * fix * Update queue/worker_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * optimize --------- Co-authored-by: krishan kumar <84431594+kkumar-gcc@users.noreply.github.com> Co-authored-by: ALMAS <almas.cc@icloud.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>



📑 Description
Related to:
urfave/cli#1242
urfave/cli#2176
Previous:
Current:
✅ Checks