Repository navigation
Closed
Labels
review: lowghfind author score; see https://ghfind.com
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
Dify version
dify-client 3.1.0 (Node.js SDK, sdks/nodejs-client), main @ 310ce87f9d
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
The SDK README says to "use stream.toText() to collect text" for streaming responses. toText() in sdks/nodejs-client/src/http/sse.ts only reads top-level answer / text / delta fields and appends every event. That breaks two documented stream shapes:
- Workflow apps return an empty string. The workflow pipeline streams its text output as
text_chunkevents, where the text is nested asdata.text(TextChunkStreamResponseinapi/core/app/entities/task_entities.py).toText()never looks there. - Output moderation is appended instead of applied.
message_replacecarries the full replacement answer (MessageReplaceStreamResponse), and the web app setscontent = messageReplace.answer.toText()appends it to the text already streamed, so the moderated output is still returned.
Minimal repro with the SDK's own stream helper (no server needed):
import { Readable } from 'node:stream'
import { createSseStream } from './src/http/sse'
const workflow = Readable.from([
'data: {"event":"text_chunk","data":{"text":"Hello"}}\n\n',
'data: {"event":"text_chunk","data":{"text":" world"}}\n\n',
])
console.log(JSON.stringify(await createSseStream(workflow, { status: 200, headers: {} }).toText()))
// ""
const moderated = Readable.from([
'data: {"event":"message","answer":"unsafe output"}\n\n',
'data: {"event":"message_replace","answer":"Sorry, I cannot answer that.","reason":"output_moderation"}\n\n',
])
console.log(JSON.stringify(await createSseStream(moderated, { status: 200, headers: {} }).toText()))
// "unsafe outputSorry, I cannot answer that."Against a real server, the same happens with await (await client.runWorkflow(inputs, user, true)).toText() on a workflow app, and with a chat app that has output moderation enabled.
✔️ Expected Behavior
- Workflow stream:
"Hello world" - Moderated stream:
"Sorry, I cannot answer that."(the replacement, as the web app shows it)
❌ Actual Behavior
- Workflow stream:
"" - Moderated stream:
"unsafe outputSorry, I cannot answer that.". The text that moderation was meant to remove is still returned.
I have a small fix with regression tests and will open a PR.
Reacted by dosubot
Metadata
Metadata
Assignees
Labels
review: lowghfind author score; see https://ghfind.com
Activity
fix(nodejs-client): collect workflow text_chunk and apply message_rep…
Stream29 commentedon Oct 16, 2026
Reproduced both issues: workflow streams return empty text, and
message_replaceappends instead of replacing the previous text.