Skip to content

fix(ts-sdk): drop delisted markets on reconnect - #285

Open
worlldz wants to merge 1 commit into
podnetwork:mainfrom
worlldz:fix/refresh-delisted-markets
Open

fix(ts-sdk): drop delisted markets on reconnect#285
worlldz wants to merge 1 commit into
podnetwork:mainfrom
worlldz:fix/refresh-delisted-markets

Conversation

@worlldz

Copy link
Copy Markdown

Summary

  • track every market seen in the authoritative static list, not only cache-hydrated entries
  • remove a previously listed market when a reconnect seed no longer returns it
  • preserve dynamics-only entries buffered from the WebSocket until static metadata arrives

Why

marketsSource cleared its set of cache-seeded IDs after the first REST response and never repopulated it. A market delisted later therefore survived every reconnect seed in byId and remained visible for the lifetime of the client.

The regression test covers the initial seed, the duplicate cold-open seed, and a later reconnect whose static list no longer contains one market.

Verification

  • npm run typecheck
  • npm test — 12 files, 143 tests
  • npm run build

@poszu
poszu requested review from 0zzy-o and a balanced review from CopilotSeptember 1, 2026 09:03
CopilotAI reviewed Sep 1, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Out-of-order concurrent seed responses can restore a delisted market.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

for (const id of fromCache) if (!fresh.has(id)) { byId.delete(id); orderIndex.delete(id); }
fromCache.clear();
markets.forEach((m, i) => { orderIndex.set(m.id, i); byId.set(m.id, { ...byId.get(m.id), ...m }); });
for (const id of staticIds) if (!fresh.has(id)) { byId.delete(id); orderIndex.delete(id); }
Sign up for freeto 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

@worlldz