Skip to content

Keep the worker serving after the first request; test on the rapira/testing doubles - #4

Merged
roxblnfk merged 3 commits into
1.xfrom
refactor/sdk-doubles
Oct 6, 2026
Merged

roxblnfk merged 3 commits into
1.xfrom
refactor/sdk-doubles

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🔍 What was changed

  • Fix: the Worker-mode handler now returns true. Rapira\handle_request() takes a callable(): bool and keeps the worker serving only while it answers true; the handler returned nothing, so a worker could end after its first request and be restarted by the host — Worker mode silently behaving like Classic.
  • Fix: Classic and Worker mode send the response inside an output buffer. A streamed callback calling ob_flush() needs one; php-fpm has it from output_buffering, the Rapira SAPI starts without, so the notice became an exception after the first chunk and streamed responses were cut short. The acceptance suite now runs and caught it.
  • The internal Runtime / ExtensionRuntime seam is gone: the runner calls Rapira\get_mode(), get_dispatcher(), handle_request() and rapira_finish_request() directly. Runner's constructor loses its internal $runtime parameter.
  • Tests script the runtime with FakeRuntime, FakeHttpDispatcher and FakeExchange from rapira/testing instead of the local copies.

Why?

The seam existed only so tests could replace the extension. Since rapira/contract 0.9.1 the contract's own stubs answer through a replaceable runtime, and rapira/testing ships the doubles the yii and laravel bridges each kept a copy of.

Checklist

  • How was this tested:

Review notes

`Rapira\handle_request()` takes a `callable(): bool` and keeps the worker serving only while it answers true. The handler returned nothing, so a worker could end after its first request and be restarted by the host, which turns Worker mode into Classic. The bridge's own test runtime ignored the result and hid it.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
test: script the Rapira runtime with FakeRuntime, FakeHttpDispatcher and FakeExchange from rapira/testing

The internal `Runtime` existed only so tests could replace the extension. Since rapira/contract 0.9.1 the contract's own stubs answer through a replaceable runtime, so the runner calls `Rapira\*` directly and `Runner` loses its internal constructor parameter. The local fakes give way to the shared ones in rapira/testing 0.1.6.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk requested a review from a team as a code owner October 6, 2026 16:08
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3c684a02-2ba7-460e-8046-349dbd92da34
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

A streamed callback that calls `ob_flush()` needs an open buffer. php-fpm has one from `output_buffering`; the Rapira SAPI starts without, so the call raised a notice that Laravel turned into an exception after the first chunk, and Classic and Worker mode cut streamed responses short.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk merged commit da8455f into 1.x Oct 6, 2026
7 checks passed
@roxblnfk
roxblnfk deleted the refactor/sdk-doubles branch October 6, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant