GitHub Repo
Dify Community Proposes Node.js SDK Streaming Fix; Replacement Events May Preserve Original Text
A report on October 15 found that Node.js SDK’s `toText()` may miss workflow text and append content moderation replacement messages to the original answer. The fix includes regression tests but has not been merged; an official release version is still unconfirmed.

On October 15, the Dify community reported a streaming collection bug in the Node.js SDK, involving dify-client 3.1.0 and the listed main-branch version. The stream.toText() method, which gathers a reply, may return an empty string when a workflow has produced text. For content moderation replacement events, it may also retain the original answer that should have been replaced. Another contributor reported reproducing both behaviors on the 16th. Report and reproduction
The issue stems from event semantics and field locations. The existing collector reads top-level answer, text, or delta fields, but a workflow’s text_chunk puts text in data.text, so the collector ignores it. Meanwhile, message_replace carries a complete replacement answer; if the collector continues appending, the final string contains both the original content and the moderated reply. The report includes a synthetic SSE test that checks the collector’s behavior without starting a server. Technical details
A fix proposed the same day reads nested text specifically for text_chunk and overwrites accumulated content for message_replace. Other nested events remain ignored, to avoid mixing reasoning text into the answer. The author says they added two regression tests; all 139 SDK tests passed, as did type and formatting checks. The proposal is still open and awaiting review by a code owner. Proposed fix
This directly matters to custom chat interfaces and agent backends: based on the reported behavior, downstream systems that save the collected result or pass it to another tool may continue using the original text, even when the server sends a moderation replacement message. Dify’s official documentation also calls for dispatching by event type and distinguishing text chunks, completion, and error events, underscoring that streaming integrations need to maintain reply state. Official streaming guide
Engineering teams can first check their SDKs and wrapper layers against a fixed event sequence covering nested text, replacement answers, and the final stored result. They should then track the fix’s merge and package release. Current evidence points to an issue in a specific collector function and does not establish that all Dify clients or deployments are affected.