fix(grok-web): stop streaming errors from reporting false success - #12458
Merged
diegosouzapw merged 5 commits intoSep 3, 2026
Merged
Conversation
…1-grok-web-stream-error-boundary
…grok-web-stream-error-boundary
diegosouzapw
marked this pull request as ready for review
September 3, 2026 23:59
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…egosouzapw#12458) Validado em lote numa worktree combinada com os 14 PRs desta campanha de error-boundary sobre o tip de `release/v3.8.51`: `typecheck:core` limpo e **120/120** nos 23 arquivos de teste que os PRs trazem. Um ponto que só apareceu no tree combinado: **diegosouzapw#12465 e diegosouzapw#12466 criam o mesmo arquivo novo** `open-sse/utils/streamReadiness.ts` (que não existe no tip) com desenhos divergentes de cancelamento — `cancelled` + `releaseLock` imediato num, `readInFlight`/`cancelRequested` com `cancelReader` fire-and-forget no outro. Adotei a versão do diegosouzapw#12466, que difere e defere o release do lock para quando a leitura em voo termina, e validei a escolha rodando as suítes dos **dois** PRs contra ela: 21/21 no readiness compartilhado e 22/22 incluindo o boundary do Perplexity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grok Web could translate an upstream NDJSON error into normal assistant content, then emit a
successful
stop+[DONE]sequence under HTTP 200. This change makes the producer preserve theactual failure boundary without depending on the shared stream hardening work.
success:falseto the outer fallback contract[Error: ...], followed bystopstopThe assistant role is now delayed until real content, reasoning, or a tool call exists. Existing
streaming tool-call behavior remains intact.
Security and lifecycle properties
onStreamFailure/pipeline persistence path exactlyonce and persist the fixed public message with status 502.
stop,[DONE], or error log and propagates to the upstreamreader exactly once, even when the upstream
cancel()promise never resolves.globals, database, or call-log writer. This is required because the fast unit suite can run with
--test-isolation=none.path/module/locale/temp values,
NODE_ENV=test, a synthetic test-onlyAPI_KEY_SECRET, andbackup/color test flags. No provider credential or token is inherited.
DATA_DIRandOMNIROUTE_PLUGINS_DIR, blocks ambientfetch, stubsevery Grok event stream, drains and closes call-log resources, resets the DB, closes the shared
logger, and only then removes its temporary directory.
Evidence
7802f6ea163f18f349348dbfd8710a159ac32e150, expected1DATA_DIR/DB state--test-isolation=nonewrapper + call-log drain reproopenSseTypecheckErrors=0config/quality/eslint-suppressions.jsongit diff --checke243b04de22da2d78900c27fde5f83f4fbc3d7f9without conflicts; focused 82/82 tests and gates rerun on candidate93b1f7d1256d388bbb547dc8a172ad3a7d74abcaFinal candidate was reconciled with live release SHA
e243b04de22da2d78900c27fde5f83f4fbc3d7f9; exact head is93b1f7d1256d388bbb547dc8a172ad3a7d74abca.Scope boundary / follow-up
This PR deliberately fixes the streaming path only. The adjacent non-streaming Grok path still
uses the upstream
chunk.errorwhen building its JSON 502 response; that needs a separate,focused sanitization PR and is not hidden by this change.