Skip to content

stream() computes default pageSize before ready(), which can break live streaming #173

@cybito

Description

@cybito

Hi, I found a live-streaming issue in PineTS 0.9.7.

stream() computes the default pageSize before await this.ready():

const pageSize = options.pageSize || this.data.length;

At that point this.data.length can still be 0, so pageSize becomes 0 and is never recomputed later.

This can break _runPaginated() / live streaming behavior:

  • ctx.idx may stay at 0
  • ctx.marketData[ctx.idx] may point to an old historical candle instead of the latest candle
  • the historical/live branch in stream() can misclassify the current candle
  • in practice this caused repeated processing of the same candle, no bar progression, and in some runs a hot loop with very high CPU usage

Relevant code:

  • src/PineTS.class.ts: stream()
  • src/PineTS.class.ts: _runPaginated()

Suggested fix:

  • compute the fallback pageSize after await this.ready(), or
  • lazily resolve the default from the loaded data before calling _runPaginated()

Workaround on the consumer side:

  • pass an explicit pageSize to stream()

I can provide a minimal repro if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions