Skip to content

[WebConsole] Fix page sometimes goes blank on high-throughput change stream#4102

Closed
Karakatiza666 wants to merge 1 commit into
mainfrom
fix-ui
Closed

[WebConsole] Fix page sometimes goes blank on high-throughput change stream#4102
Karakatiza666 wants to merge 1 commit into
mainfrom
fix-ui

Conversation

@Karakatiza666
Copy link
Copy Markdown
Contributor

@Karakatiza666 Karakatiza666 commented May 31, 2025

Fix header disappearing at the top of a long change stream

The cause of the issue going blank was due to the way backpressure relief when parsing high-throughput change stream JSON was implemented. Previously when backpressure occurred new cunks of data were simply discarded, but the parsing was re-attempted; usually skipping chunks of json string caused parsing to fail immediately, but sometimes dropping chunks results in a syntactically valid, but structurally invalid JSON, so the parsing succeeded, but the result values were unpredictable. These events caused UI to crash as malformed JSON objects propagated in the UI.
The fix is to re-start parsing when backpressure was relieved by dropping chunks of the stream

@Karakatiza666 Karakatiza666 requested a review from gz May 31, 2025 00:52
@Karakatiza666 Karakatiza666 added bug Something isn't working Web Console Related to the browser based UI javascript Pull requests that update Javascript code UX Issues that effect an end-user's experience labels May 31, 2025
…stream

Fix header disappearing at the top of a long change stream

Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
@gz
Copy link
Copy Markdown
Contributor

gz commented Jun 3, 2025

syntactically valid, but structurally invalid JSON

I don't understand what this means

In any case, this general code area has been a recurring problem zone riddled with bugs it would be good to find out if there are any standard/simple solutions we're missing for this

@Karakatiza666
Copy link
Copy Markdown
Contributor Author

{ "foo": "foo", "bar": "bar" } -> { "foobar": "bar" }

@Karakatiza666
Copy link
Copy Markdown
Contributor Author

I observe reduced perceived performance of change stream updates, I want to do another pass on this

Copy link
Copy Markdown

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

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

Behavioral change — stream handling refactored from parseCancellable to BatchingWritableStream — with no tests added.

batchTimeoutMs?: number
}

export class BatchingWritableStream<T> extends WritableStream<T> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New BatchingWritableStream class introduces batching logic, back-pressure via setTimeout, and a batchTimeoutMs flush timer. This is non-trivial behavior that can fail in subtle ways (e.g., timer not cleared on abort, races between flush and close). Per Gerd's directive (2026-03-04): behavioral changes to the web-console require tests. Recommended stack: Vitest + @testing-library/svelte. Good starting target: unit tests for flushBatch logic and the abort path, without mounting any component.

@Karakatiza666
Copy link
Copy Markdown
Contributor Author

Superceded by #6215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript Pull requests that update Javascript code UX Issues that effect an end-user's experience Web Console Related to the browser based UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants