Skip to content

fix(php-sdk): avoid buffering streaming responses - #44271

Merged
crazywoola merged 3 commits into
langgenius:mainfrom
Winoren:fix/php-sdk-workflow-stream
Oct 30, 2026
Merged

crazywoola merged 3 commits into
langgenius:mainfrom
Winoren:fix/php-sdk-workflow-stream

Conversation

@Winoren

@Winoren Winoren commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #44270.

The PHP SDK requests server streaming but buffers the complete response in two methods: WorkflowClient::run(..., 'streaming', ...) and DifyClient::text_to_audio(..., true). Both omit the final streaming argument to send_request, leaving Guzzle's stream option false.

Forward the existing streaming setting in both calls, matching the PHP chat and completion clients. Preserve public signatures, routes, JSON payloads, and buffered/default behavior. Add one standalone request regression script for both methods and document incremental SSE/audio consumption. For TTS this controls client buffering; whether the provider generates audio incrementally is a separate server behavior.

These two missing argument forwards share the same cause and are covered together in this PR.

Validation

  • Workflow request regression failed on the original implementation. The TTS request regression failed on the preceding PR head b00c3867, while the existing workflow checks passed. After the combined fix, both methods pass streaming/buffered option, endpoint, payload, Authorization, and response assertions through the real SDK/Guzzle preparation with only transport replaced.
  • Separate real local HTTP fixtures immediately flush initial bytes and wait 3 seconds before the final bytes. Workflow: original returned after 3.034 seconds, fixed after 0.018 seconds. TTS: preceding PR head returned after 3.058 seconds, fixed after 0.020 seconds, then read the initial RIFF bytes before the delayed tail. These use real HTTP and Guzzle rather than the request test's mock transport.
  • PHP 8.5.10 via WordPress PHP.wasm CLI 3.1.57, locked Guzzle 7.15.5, installed from the unchanged Composer lockfile.
  • php -l dify-client.php and php -l tests/streaming_test.php: no syntax errors; git diff --cached --check: clean.
  • Fixture timings demonstrate buffering behavior, not production performance, valid audio decoding/playback, provider invocation, or full Dify workflow execution. Native PHP/cURL and the PHP 7.2 minimum-version matrix were not run. This SDK has no PHP static-analysis/build configuration; no backend/frontend code changes or full monorepo checks were run. Remote checks are rerunning for the updated commit; PHP regression execution is local, not a claim that CI runs this script.

From sdks/php-client:

composer install
php tests/streaming_test.php

Screenshots

Not applicable (PHP SDK).

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly (SDK README).
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

AI assistance: Codex investigated, implemented, and ran the checks reported here; no independent human review is claimed.

From Codex

@ghfind-review ghfind-review Bot added the review: medium ghfind author score; see https://ghfind.com label Oct 17, 2026
@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 17, 2026
@Winoren Winoren changed the title fix(php-sdk): stream workflow responses incrementally fix(php-sdk): avoid buffering streaming responses Oct 18, 2026
@github-actions github-actions Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Oct 18, 2026
@crazywoola
crazywoola added this pull request to the merge queue Oct 30, 2026
Merged via the queue into langgenius:main with commit eff2623 Oct 30, 2026
34 checks passed
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: medium ghfind author score; see https://ghfind.com size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP workflow streaming requests buffer the full SSE response

2 participants