cnpm / cnpmcore

Private NPM Registry for Enterprise
https://npmmirror.com
MIT License
607 stars 80 forks source link

fix: unpkg lock #629

Closed elrrrrrrr closed 9 months ago

elrrrrrrr commented 9 months ago

When accessing the unpkg service, when the packages have not yet been synchronized, will lead to multiple synchronization attempts concurrently causing db insert errors.

  • 🔒 Added a Redis lock for the ensurePackageVersionFilesSync function, with a default timeout of 60 seconds.
  • 🥸 Admin PUT requests and the package version auto sync process are not restricted by this.

当访问 unpkg 服务时,如果访问存量未同步的包,可能导致多次同步并发报错

  • 🔒 为 ensurePackageVersionFilesSync 添加 redis 锁,默认超时 60s
  • 🥸 管理员手动 PUT 请求和包同步流程不受限制
codecov[bot] commented 9 months ago

Codecov Report

Attention: 166 lines in your changes are missing coverage. Please review.

Comparison is base (6624a36) 97.45% compared to head (f4d416c) 96.85%. Report is 151 commits behind head on master.

Files Patch % Lines
config/config.default.ts 56.33% 31 Missing :warning:
.../port/controller/admin/PaddingVersionController.ts 48.83% 22 Missing :warning:
app/core/service/FixNoPaddingVersionService.ts 54.54% 15 Missing :warning:
app/core/service/PackageSearchService.ts 93.72% 15 Missing :warning:
app/core/service/PackageSyncerService.ts 85.84% 15 Missing :warning:
app/port/schedule/SyncBinaryWorker.ts 21.42% 11 Missing :warning:
app/repository/PackageVersionRepository.ts 87.95% 10 Missing :warning:
app/core/service/PackageVersionFileService.ts 92.59% 8 Missing :warning:
app/core/entity/PaddingSemVer.ts 88.00% 6 Missing :warning:
app/core/service/PackageVersionService.ts 94.91% 6 Missing :warning:
... and 10 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #629 +/- ## ========================================== - Coverage 97.45% 96.85% -0.60% ========================================== Files 168 180 +12 Lines 15691 17567 +1876 Branches 2018 2290 +272 ========================================== + Hits 15291 17014 +1723 - Misses 400 553 +153 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.