Skip to content

[#507] fix: make delivery recording recoverable when contract call fails - #533

Open
payfoxX wants to merge 3 commits into
JSE-ORG:devfrom
payfoxX:fix/507-tracking-worker-order
Open

[#507] fix: make delivery recording recoverable when contract call fails#533
payfoxX wants to merge 3 commits into
JSE-ORG:devfrom
payfoxX:fix/507-tracking-worker-order

Conversation

@payfoxX

@payfoxX payfoxX commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #507

Problem

TrackingPollWorker.run called markDelivered BEFORE recordDelivery. If the contract call failed, the escrow was already DELIVERED in the database, so findShippedWithTracking would not return it again. The contract was never told, and no retry was possible.

Solution

Reversed the order: call recordDelivery FIRST, then markDelivered. If the chain call fails, the escrow remains SHIPPED and will be retried on the next poll cycle. This follows the same claim-before-chain pattern used by AutoReleaseWorker.

Changes Made

  • src/workers/tracking-poll.worker.ts: Swapped recordDelivery before markDelivered
  • test/unit/tracking-poll.worker.spec.ts: Updated test to reflect new call order

Test Results

All 3 existing tests pass.

…all fails

Swapped the order of operations in TrackingPollWorker.run: contractService.recordDelivery is now called before escrowRepository.markDelivered. If the chain call fails, the escrow remains in SHIPPED state and will be retried on the next poll cycle. This follows the same claim-before-chain pattern used by AutoReleaseWorker.

Closes JSE-ORG#507
@payfoxX
payfoxX requested a review from Omoboi-dev as a code owner July 29, 2026 01:42
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Myart352 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! 🚀

Learn more about application limits

@payfoxX payfoxX changed the title fix(workers): make delivery recording recoverable when the contract call fails [#507] fix: make delivery recording recoverable when contract call fails Jul 29, 2026
payfoxX added 2 commits July 29, 2026 01:48
The @optional() decorator was used without importing Optional from @nestjs/common. This caused tests importing PrismaService to fail.
Fixed duplicated content in escrow.service.spec.ts (3 copies -> 1), sync throw issue in prisma.service.spec.ts, and missing closing brace in api-keys.controller.spec.ts. These are pre-existing bugs on dev that were causing CI failures.
@Omoboi-dev

Copy link
Copy Markdown
Contributor

check and resolve your conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delivery is recorded in the database before the contract call, and a failure loses the escrow

2 participants