Repository navigation
Fix: 4 issues (#83, #84, #85, #86) - #132
Merged
victorisiguzoruzoma874 merged 3 commits intoOct 18, 2026
Merged
Conversation
Co-authored-by: Simple Agent <agent@simple.dev>
|
@Kaselchumfa is attempting to deploy a commit to the work Team on Vercel. A member of the Team first needs to authorize it. |
|
@Kaselchumfa Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
- src/db/schema.ts: merged [markers] — model resolved the conflict markers - src/workers/retryPendingWorker.ts: merged [markers] — model resolved the conflict markers Co-authored-by: Simple Agent <agent@simple.dev>
- src/db/schema.ts: merged [markers] — model resolved the conflict markers Co-authored-by: Simple Agent <agent@simple.dev>
victorisiguzoruzoma874
merged commit Oct 18, 2026
ac35562
into
SynapsVault:main
1 of 4 checks passed
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.
Closes #83
Closes #84
Closes #85
Closes #86
Issues
#83 Retry worker never marks a resource failed when the existence check keeps erroring
#84 Retry attempt counts live in memory and reset on every restart
#85 Retry worker ticks can overlap and process an unbounded backlog one by one
#86 Payment is recorded before the file is delivered, with no delivery status
Summary
The migration file drizzle/0011_onchain_attempts.sql already exists but is empty; fill it in rather than creating a new migration. Use an atomic SQL increment for onchain_attempts to avoid races between overlapping ticks. The in-flight guard should be reset in a finally block so a thrown error cannot permanently wedge the worker. For #86, prefer fetching content before inserting the payment; if the payment must be inserted first for other reasons, set delivery_status='undelivered' on failure and log at error level with resourceId and paymentId. Add tests: resourceExists rejects four times -> status 'failed' (#83); worker restart preserves count and enforces limit (#84); two overlapping ticks run one batch and batch size is configurable (#85); downloadFile throws -> payment marked undelivered and error logged (#86).
Changes
onchainAttemptsinteger column to theresourcestable (nameonchain_attempts, not null, default 0) so retry attempt counts persist across worker restarts. Also add adeliveryStatustext column to thepaymentstable (namedelivery_status, not null, default 'delivered') so undelivered payments can be marked and reconciled. Export both in the Drizzle schema. (src/db/schema.ts)ALTER TABLE resources ADD COLUMN onchain_attempts integer NOT NULL DEFAULT 0;andALTER TABLE payments ADD COLUMN delivery_status text NOT NULL DEFAULT 'delivered';. This backs the persisted attempt counter (Retry attempt counts live in memory and reset on every restart #84) and the payment delivery status (Payment is recorded before the file is delivered, with no delivery status #86). (drizzle/0011_onchain_attempts.sql)RETRY_WORKER_BATCH_SIZE(coerced number, default e.g. 25) andRETRY_WORKER_ITEM_TIMEOUT_MS(coerced number, default e.g. 30_000), so the retry worker's batch limit and per-item timeout are configurable (Retry worker ticks can overlap and process an unbounded backlog one by one #85). (src/config.ts)onchainAttemptsin the DB before any RPC call (atomicUPDATE ... SET onchain_attempts = onchain_attempts + 1 RETURNING onchain_attempts), and in the catch path mark the resourcefailedwhen the persisted count exceedsMAX_RETRY_ATTEMPTS, regardless of which call threw — so aresourceExiststhat rejects four times ends with statusfailed. (Retry attempt counts live in memory and reset on every restart #84) Remove the in-memoryretryCountsMap entirely; read and enforce the limit from the persistedonchain_attemptscolumn so counts and the limit survive a worker restart. (Retry worker ticks can overlap and process an unbounded backlog one by one #85) Add a module-level in-flight boolean guard so overlappingtickcalls run only one batch, apply a configurableLIMIT(fromconfig.RETRY_WORKER_BATCH_SIZE) to the pending-resources query, and wrap each item'sretryResourcecall in a per-item timeout (config.RETRY_WORKER_ITEM_TIMEOUT_MS) so a slow RPC cannot stall the batch. (src/workers/retryPendingWorker.ts)downloadFilebefore inserting the payment row (for file resources); ifdownloadFilethrows, record the payment withdeliveryStatus: 'undelivered'(or skip recording and log), log an error with resource and payment identifiers for reconciliation, and return an error to the buyer. When delivery succeeds, record the payment withdeliveryStatus: 'delivered'. Keep the link-resource path recording payments as delivered. (src/routes/resources.ts)