Repository navigation
feat(batch): batch.onLocked — wait or fail instead of silently paying exact when another process owns the channel - #97
Merged
Conversation
…hannel lock instead of paying exact Refs #96. Batch pays in one process per wallet; other processes paid exact silently. onLocked: "exact" (default, unchanged) | "wait" (up to lockWaitMs, default 60 s) | "throw" (BatchChannelLockedError, unpaid, nothing signed). README now states the one-process-per-wallet rule.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #96 (the docs and option half; multi-process channel sharing stays open there).
Problem
Batch pays in one process per wallet: the process that opens the channel holds the store's lock until it exits. Other processes on the wallet (worker pools, PM2/cluster, parallel benchmarks) paid
exact, 1.5–2.5x the metered price, and the only sign was achannel_store_lockedfallback event. Agent Money Bench hit it 3/3 times with 3 processes.Change
batch.onLocked: "exact" | "wait" | "throw", default"exact", so nothing changes unless you opt in."wait": onebackoffevent (channel_store_locked), then the lock is tried every 500 ms up tobatch.lockWaitMs(default 60000). The call pays with batch once the owner exits; if the wait runs out it raises."throw": raises at once.BatchChannelLockedError(wallet,ownerPid,waitedMs). It is raised before anything is signed, with disposition"unpaid", so fallback models may move on. A process that lost its lock to another owner raises it too, unlessonLockedis"exact".Tests
Five new tests: throw (unpaid, only the challenge sent, no exact); wait then batch once the lock frees; wait running out (raises, never exact); the default stays exact; bad options are rejected. Full local CI: build, lint, tsc, 1083 passed / 12 skipped, router-core 0.