Skip to content

Emit order completed event after status update#258

Merged
roncodes merged 1 commit into
fleetbase:dev-v0.6.51from
blockalicious-io:fix/order-completed-webhook-timing
Jun 4, 2026
Merged

Emit order completed event after status update#258
roncodes merged 1 commit into
fleetbase:dev-v0.6.51from
blockalicious-io:fix/order-completed-webhook-timing

Conversation

@PremSharma-Intelegencia

@PremSharma-Intelegencia PremSharma-Intelegencia commented Jun 2, 2026

Copy link
Copy Markdown

Summary

This PR updates Order::complete() so the order.completed lifecycle event is emitted only after the order has been updated to the completed state.

Previously, notifyCompleted() was called before the completed activity/status was applied. As a result, lifecycle event consumers could receive an order.completed event while the order still exposed its previous status.

Background

Downstream listeners build lifecycle payloads from the order state at the time the completion event is emitted.

The previous order of operations was:

  1. Emit the order completed event
  2. Apply the completed activity/status

This could cause stale order data to be captured by event listeners and included in webhook payloads.

Changes

  • Move notifyCompleted() after the completed activity update in Order::complete()
  • Keep notifyCompleted() outside the completed-activity guard so callers that already applied the completed activity still emit the completion event
  • Update the method docblock to reflect the actual order of operations

Related PRs

Move Order::complete() so it applies the completed activity before firing the completion event. This keeps lifecycle event consumers from seeing stale order state while preserving the existing behavior that complete() emits the order completed event even when the completed activity was already applied by the caller.
@PremSharma-Intelegencia PremSharma-Intelegencia changed the title Fix order.completed event timing after status update Emit order completed event after status update Jun 2, 2026
@roncodes roncodes changed the base branch from main to dev-v0.6.51 June 4, 2026 05:14
@roncodes roncodes merged commit 46e61a0 into fleetbase:dev-v0.6.51 Jun 4, 2026
4 checks passed
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.

3 participants