-
Notifications
You must be signed in to change notification settings - Fork 0
WIP Switch from lockfile to proper-lockfile #517
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request updates the project's locking mechanism by replacing the legacy Changes
Sequence Diagram(s)sequenceDiagram
participant Worker as Worker Module
participant Locks as Locks Module (proper-lockfile)
participant Task as Asset Upload / Render Handler
Worker->>Locks: Request lock for resource
Locks-->>Worker: Return lockResult { wasLockAcquired, release() }
Worker->>Task: Proceed with asset upload / rendering
Task-->>Worker: Processing complete
Worker->>Locks: Invoke release() to unlock resource
Locks-->>Worker: Confirm resource unlocked
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
9e31047 to
c808823
Compare
| // so make it use that instead of ctime. | ||
| // Probably you should never do this in production! | ||
| // @ts-expect-error Not allowed by the types | ||
| lockfile.filetime = 'mtime'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proper-lockfile already uses mtime. But this test fails...
c808823 to
4235b0d
Compare
| const taskDescription = `Uploading files ${assetsDescription} to ${bundlePath}`; | ||
| const lockfileName = 'transferring-assets'; | ||
| // lock already catches errors internally, so it's safe to call without try/catch | ||
| const lockResult = await lock(lockfileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could keep the call inside try/catch, but that complicates code unnecessarily.
| let lockAcquired = false; | ||
| let lockfileName: string | undefined; | ||
| // lock already catches errors internally, so it's safe to call without try/catch | ||
| const lockResult = await lock(bundleFilePathPerTimestamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| const lockfileOptions = { pollPeriod: 100, stale: 10000 }; | ||
| lockfile.lockSync(lockfilePathForTest(), lockfileOptions); | ||
| const release = lockSync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was probably lockSync for simplicity, here we have a normal Promise-based API and can use lock instead. But it should wait until the other tests pass.
proper-lockfilehas better API and some improvements.Once CI passes:
TEST_LOCKFILE_THREADING.Summary by CodeRabbit
Summary by CodeRabbit
Chores
Refactor
Tests