44 lines
1.9 KiB
Markdown
44 lines
1.9 KiB
Markdown
# RetrieX SSE reconnect replay fix
|
|
|
|
Patch-only fix for fragile browser streaming after the job-based EventSource flow.
|
|
|
|
## Problem
|
|
|
|
EventSource is allowed to reconnect automatically when the browser, proxy or PHP/Nginx connection is interrupted. The previous job guard treated a second `/ask-sse/{jobId}` connection while the job was still `running` as an application error. In the UI this could append messages like:
|
|
|
|
```text
|
|
event: error
|
|
data: Der Antwort-Stream läuft bereits oder wurde nach einem Verbindungsabbruch erneut geöffnet...
|
|
```
|
|
|
|
This happened especially in slower Shopware/search flows, but it could also happen in pure RAG answers.
|
|
|
|
## Change
|
|
|
|
- Streamed answer chunks now receive monotonically increasing SSE `id:` values.
|
|
- Each streamed chunk is additionally written to a per-job replay buffer under `var/stream_jobs/*.stream.ndjson`.
|
|
- If EventSource reconnects to a job that is already `running`, the controller no longer emits the misleading duplicate-stream error.
|
|
- Instead, the reconnecting request reads `Last-Event-ID`, replays missing chunks and tails the still-running job until it completes, fails or is marked interrupted.
|
|
- Completed jobs can replay any missing chunks and then emit `done`.
|
|
- The frontend tracks `event.lastEventId` and ignores duplicate/replayed chunks defensively.
|
|
- Expired job cleanup also removes the replay buffer sidecar file.
|
|
|
|
## Changed files
|
|
|
|
- `src/Controller/AskSseController.php`
|
|
- `public/assets/js/base.js`
|
|
|
|
## Safety
|
|
|
|
This patch does not change retrieval, PromptBuilder, AgentRunner, scoring, intent detection, Shopware query generation or RAG behavior. It only changes the transport/reconnect layer for SSE.
|
|
|
|
## After installing
|
|
|
|
```bash
|
|
php bin/console cache:clear
|
|
php bin/console mto:agent:config:validate
|
|
php bin/console mto:agent:regression:test
|
|
```
|
|
|
|
Hard-refresh the browser or clear browser cache because `public/assets/js/base.js` changed.
|