Skip to content

LO:TECH response involving failed symbols#131

Open
hacheigriega wants to merge 4 commits into
mainfrom
hy/response-fix
Open

LO:TECH response involving failed symbols#131
hacheigriega wants to merge 4 commits into
mainfrom
hy/response-fix

Conversation

@hacheigriega
Copy link
Copy Markdown
Member

@hacheigriega hacheigriega commented May 26, 2026

Explanation of Changes

Explanation of the three commits in order:

  1. Apply changes from chore: always give back prices even when one symbol fails #130 to the lo-tech module. Also, move cleanup upon timeout error from the call sites to the shared cache.
  2. Lo-tech module now handles acknowledgement messages. The price feed map is now updated only after receiving ack messages, preventing updates when a subscription request fails.
  3. Lo-tech module also handles subscription failure errors. This helps us clean up the price feed IDs we add for every subscription request.
  4. Price fetch is now done concurrently so that timeouts do not accumulate across multiple invalid symbols.

Testing

$ curl http://localhost:5384/proxy/lotech/NVDA,WTIN6 | jq

[
  {
    "type": "PRICE",
    "symbol": "NVDA",
    "ingress_ts": 1779818875945310,
    "publish_ts": null,
    "transaction_ts": 1779818875860000,
    "price": 213.496,
    "spread": 0.01,
    "__sedaHasPrice": true
  },
  {
    "symbol": "WTIN6",
    "__sedaHasPrice": false
  }
]

Apply changes from #130 to the lo-tech module. Also, move cleanup upon
timeout error from the call sites to the shared cache.
@hacheigriega hacheigriega changed the title chore(data-proxy): response involving failures LO:TECH response involving failed symbols May 26, 2026
@hacheigriega hacheigriega requested a review from a team May 26, 2026 18:09
@hacheigriega hacheigriega marked this pull request as draft May 26, 2026 18:24
Improve lo-tech module logic by activating price feeds once ack messages
are received. Also rename variables and improve comments for clarity.
@hacheigriega hacheigriega marked this pull request as ready for review May 27, 2026 01:36
Previously, getOrWaitPrice was called sequentially in a loop, causing
the timeouts to accumulate when multiple invalid symbols were requested.
Comment on lines +93 to +94
const now = yield* Clock.currentTimeMillis;
MutableHashMap.set(lastRequestToPriceFeed, symbol.value, now);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? It reads a little weird that a message from lo-tech->proxy updates a map that tracks requests from client->proxy

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with this change we update the price feed subscription map and the last request map upon receiving ack to avoid updating these maps for invalid symbols that we have failed to subscribe for. Previously, we were tracking last request times for all the invalid symbols we receive from clients, even though there were no active price feeds for those.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah check, so if I understand it correctly the flow now is:

  • Request for symbol X
  • If new symbol, create new feedId (monotonically increasing counter) and store in priceFeedIds
  • Receive ack for an ID
  • Check if priceFeedIds contains the ID
  • If yes, make the pricefeed 'official' by adding mapping entry in priceFeeds
  • And mark it as the first request by setting a timestamp in lastRequestToPriceFeed

If this is correct I find it a little hard to get this from the code, but I also don't have an idea on how to express it differently.

I do have one question; what happens to priceFeedIds that never receive an ack? Is that a potential source of an unbounded map that doesn't get cleaned?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and yes, unfortunately. The ack message doesn't contain the symbol, so there is no way to avoid storing a symbol in priceFeedIds every time we send a subscription request.

But now that I think about it, we could handle this issue by handling the subscription failure errors we receive from the upstream. I will try that

Comment thread workspace/data-proxy/src/modules/lo-tech/lo-tech.ts
Handle subscription failure error message from LO:TECH and remove the
corresponding entry from the `priceFeedIds` map so that the map does not
grow unbounded with invalid symbols. Also includes some refactor to
improve organization of message parsing and handler dispatching.
@hacheigriega hacheigriega requested a review from Thomasvdam May 29, 2026 19:09
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.

2 participants