fix(streaming): sanitize generic stream failure boundaries - #12457
Merged
diegosouzapw merged 5 commits intoSep 3, 2026
Merged
Conversation
…streamhandler-public-errors
…streamhandler-public-errors
diegosouzapw
marked this pull request as ready for review
September 3, 2026 23:58
5 tasks done
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…apw#12457) 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
The generic stream finalizer passed raw upstream
Error.messagetext to public SSE frames and to the stream diagnostic log. A provider error containing credentials, filesystem paths, or a stack tail could therefore escape after the HTTP response had already started.chat.completion.chunk.error.messagebuildErrorBody()before encodingfinish_reason: "error", status-derived type/code, and[DONE]are unchangedresponse.failedresponse.failedevent/type/code assertionsevent: errorerror+message_stopassertionsmessage_stopare unchangedError, raw message, and status ononError; sanitize only at public/log boundarieslogStream("error: ...")logged the raw provider messageDATA_DIRand plugin state at module scope under--test-isolation=nonestreamHandler.tsstayed byte-identical during the repairOne intentional security behavior change: multiline public diagnostics now retain only the first sanitized line. This removes stack tails while preserving status, protocol framing, and the raw internal failure object.
Reconciliation summary
e243b04de22da2d78900c27fde5f83f4fbc3d7f9866f4df88bf7bf85f2b0669150104ed1e9d7429fe786e061e9f9ddcb42bdd2de7db58d8bfb73eb05origin/release/v3.8.51; no rebase or force-pushstreamHandler.tsor either isolated boundary test, and did not contain a central stream/public-error helper on which this PR could accidentally dependopen-sse/utils/streamHandler.tsretained git blob7abafbf080f92a8107962da544409fb3fd31526eacross reconciliationValidation
7802f6ea163f18f349348dbfd8710a159ac32e15DATA_DIRwas replaced by the boundary test's module-scope temp directory866f4df88btest:unit:fast-shape pair: wrapper +call-log-save-drain.test.ts, absolute paths,--test-isolation=none, no concurrency overridenpm run typecheck:coregit diff --checknpm run check:changelog-integrityorigin/release/v3.8.51npm run check:secretssecretFindings=0866f4df88bf7bf85f2b0669150104ed1e9d7429fThe child receives only a minimal runtime environment allowlist plus synthetic test configuration; it does not inherit credentials,
HOME, orCODEX_HOME. It asserts call-log drain completion, closes the artifact writer and shared logger, resets the DB, and removes its process-owned data only after those resources are closed. No external provider request or real credential was used.Independence
This PR is standalone and does not depend on any other open PR. It intentionally leaves merge, deployment, and release decisions to the maintainer.