Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer error (issue #922) #923

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}