Skip to content

fix: unsubscribe data loader on chart destroy - #838

Open
NemeZZiZZ wants to merge 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/destroy-unsubscribe-data-loader
Open

NemeZZiZZ wants to merge 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/destroy-unsubscribe-data-loader

Conversation

@NemeZZiZZ

Copy link
Copy Markdown
Contributor

Problem

Store.destroy() never unsubscribes the data loader. _processDataUnsubscribe() is called only from resetData() (verified: it is the single call site in src/).

After dispose(), a live subscribeBar callback keeps firing into the dead store:

subscribeBar.callback(bar)
  → Store._addData(bar, 'update')        // Store.ts
  → _adjustVisibleRange()                // bar is appended
  → _chart.layout({ ... })               // layout scheduled on a destroyed chart

Impact

For the standard realtime setup (setDataLoader with subscribeBar) + dispose(): the subscription keeps pushing bars into the destroyed chart's store — _dataList grows without bound, CPU is spent on every tick, and layout is scheduled on a dead chart. The loader's unsubscribeBar is never given the chance to run.

Fix

Call _processDataUnsubscribe() at the start of Store.destroy(), mirroring resetData(). The method already no-ops safely when loader/symbol/period are missing and uses unsubscribeBar?.() for loaders without it.

One line, one file.

This branch has not been deployed

No deployments
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.

1 participant