-
Notifications
You must be signed in to change notification settings - Fork 0
fix: handle missing emitter venues #87
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: main
Are you sure you want to change the base?
fix: handle missing emitter venues #87
Conversation
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| work.BotEvent = *latestEvent | ||
| } | ||
| if err := e.emitter.Emit(ctx, work); err != nil { | ||
| e.logger.Warn("could not submit order", slog.Any("orderid", oid), slog.Any("action", action), slog.String("error", err.Error())) | ||
| return fmt.Errorf("emit order %s: %w", oid.Hex(), err) |
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.
Returning on emitter failure loses the order on retry
The new Emit error is returned so the work item gets requeued, but processDeal only populates the seen map for events that were newly inserted in this invocation. When the requeued call runs, RecordThreeCommasBotEvent hits the sql.ErrNoRows path and the previously failed order ID is not added to seen, so the loop at the end never calls the emitter again and the order is permanently dropped even if the underlying emitter issue is later resolved. Consider either adding the order to seen before recording it or ensuring requeued invocations re-run reduceOrderEvents for already-stored events so failed emissions can be retried.
Useful? React with 👍 / 👎.
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.
@codex this is a potentially interesting problem, please investigate what reasons the emitter.Emit could have why it could return an error. My suspicion is that it got rejected, we should just simply handle the error then.
The event would replay anyway on next run, so would simply be throwing another error (as opposed to now logging another).
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.
Summary
- Pre-populated the
seenmap with actionable bot events before persisting so that requeued work items re-runreduceOrderEventsafter an emission failure. engine/engine.goL239-L256
Testing
⚠️ go test ./engine(interrupted after hanging locally).
Summary
Fixes #83
https://chatgpt.com/codex/tasks/task_e_690beedb3bc48326a7bf01b5ab2a91f9