Skip to content

Commit 7b63984

Browse files
committed
fix(editor): fall back to the queue for good once a publish fails
1 parent 030b23d commit 7b63984

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

app/Services/RpcBridge.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ public function call(Server $server, RpcAction $action, array $payload = []): ar
4343
RpcRequested::dispatch($server, $requestId, $action, $payload);
4444
} catch (Throwable $failure) {
4545
// The channel is the fast path, not the only one. Queue the
46-
// request so the plugin still finds it on its next poll.
47-
Log::warning('Could not publish an RPC request, queueing it', ['reason' => $failure->getMessage()]);
46+
// request so the plugin still finds it on its next poll, and
47+
// stop preferring a publish that just failed: every further
48+
// attempt would pay the same timeout before falling back.
49+
Log::warning('Could not publish an RPC request, falling back to the queue', [
50+
'server' => $server->uuid,
51+
'reason' => $failure->getMessage(),
52+
]);
53+
54+
$server->update(['uses_polling' => true]);
4855
$this->enqueue($server, $requestId, $action, $payload);
4956
}
5057
}

tests/Feature/BroadcastFailureTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ public function test_a_request_that_cannot_be_published_is_queued_for_the_next_p
8484
$this->assertCount(1, $bridge->collectPending($server));
8585
}
8686

87+
public function test_stops_preferring_a_channel_that_could_not_be_published_to(): void
88+
{
89+
config(['editor.rpc.timeout' => 0.2, 'editor.rpc.poll_interval_ms' => 20]);
90+
$server = Server::factory()->onChannel()->create();
91+
92+
rescue(fn () => app(RpcBridge::class)->call($server, RpcAction::MenuList));
93+
94+
$this->assertTrue($server->refresh()->uses_polling);
95+
}
96+
8797
private function readySession(): EditorSession
8898
{
8999
return EditorSession::factory()

0 commit comments

Comments
 (0)