Skip to content

Commit

Permalink
Fix buffer error (issue #922) (#923)
Browse files Browse the repository at this point in the history
* fix buffer error

* add test

* fix formatting

* fix formatting

* fix formatting
  • Loading branch information
atom1285 authored Jul 5, 2024
1 parent b5228f9 commit 68db606
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public function handle(Request $request, RequestContext $context): void

$output = ob_get_contents();

ob_end_clean();
if (ob_get_level()) {
ob_end_clean();
}

// Here we will actually hand the incoming request to the Laravel application so
// it can generate a response. We'll send this response back to the client so
Expand Down
21 changes: 21 additions & 0 deletions tests/WorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,25 @@ public function test_worker_can_dispatch_ticks_to_application_and_returns_respon

$worker->runTicks();
}

/** @test */
public function test_worker_doesnt_throw_buffer_error()
{
[$app, $worker, $client] = $this->createOctaneContext([
Request::create('/test'),
]);

$app['router']->get('/test', function () {
while (ob_get_level() !== 0) {
ob_end_clean();
}

return 'Test Response';
});

$worker->run();

$this->assertCount(1, $client->responses);
$this->assertEquals('Test Response', $client->responses[0]->getContent());
}
}

0 comments on commit 68db606

Please sign in to comment.