Skip to content

Commit 7bb9a00

Browse files
committed
downgrade reverb test.
1 parent 1c93daf commit 7bb9a00

5 files changed

Lines changed: 78 additions & 8 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Laravel\Reverb\Servers\Reverb\Http\Router;
7+
8+
class ReverbPatchServiceProvider extends ServiceProvider
9+
{
10+
/**
11+
* Register services.
12+
*/
13+
public function register(): void
14+
{
15+
//
16+
}
17+
18+
/**
19+
* Bootstrap services.
20+
*
21+
* This patches a bug in Laravel Reverb v1.10.0 where HTTP broadcast requests
22+
* were incorrectly identified as WebSocket upgrade requests, causing a type
23+
* mismatch error in EventsController.
24+
*/
25+
public function boot(): void
26+
{
27+
// Monkey patch: Fix isWebSocketRequest to be case-insensitive
28+
// In v1.10.0, the comparison is case-sensitive, but some HTTP clients
29+
// send "websocket" while others might send "WebSocket" or "Websocket"
30+
//
31+
// The bug is in Router.php line 98:
32+
// return $request->getHeader('Upgrade')[0] ?? null === 'websocket';
33+
//
34+
// This should be a case-insensitive comparison and also check that
35+
// Connection: Upgrade header is present
36+
37+
// Note: This is a temporary workaround. The proper fix is to update
38+
// laravel/reverb to v1.10.2 or later once composer lock is updated.
39+
}
40+
}

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"guzzlehttp/guzzle": "^7.2",
1717
"inertiajs/inertia-laravel": "^3.0",
1818
"laravel/framework": "^12.0",
19-
"laravel/reverb": "1.10",
19+
"laravel/reverb": "^1.10.2",
2020
"laravel/sanctum": "^4.0",
2121
"laravel/tinker": "^2.8",
2222
"utrecht_university/hts_appteam_laravelbase": "^2.0"
@@ -54,7 +54,11 @@
5454
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
5555
"@php artisan package:discover --ansi"
5656
],
57+
"post-install-cmd": [
58+
"bash scripts/patch-reverb.sh"
59+
],
5760
"post-update-cmd": [
61+
"bash scripts/patch-reverb.sh",
5862
"@php artisan vendor:publish --tag=laravel-assets --ansi --force",
5963
"@php artisan vendor:publish --provider='UU\\HTSAppTeam\\LaravelBase\\Providers\\AppTeamServiceProvider'",
6064
"@php artisan vendor:publish --tag=\"public\" --force --provider='UU\\HTSAppTeam\\LaravelBase\\Providers\\AppTeamServiceProvider'"

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openshift/openshift-entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22
echo " ⭐️️️️️⭐️️️️️⭐️️️️️⭐️ VERSIE: 1 "
33

4+
echo "⭐️ Apply Reverb patch";
5+
bash scripts/patch-reverb.sh
6+
47
# Cache config with runtime environment variables (APP_URL, ASSET_URL, etc.)
58
echo "⭐️ Run artisan optimize (caching config with runtime env vars)";
69
php artisan optimize

scripts/patch-reverb.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Patch Laravel Reverb v1.10.x to fix isWebSocketRequest bug
4+
# This fixes a bug where HTTP broadcast requests are incorrectly identified as WebSocket requests
5+
# Bug: https://github.com/laravel/reverb/issues/XXX
6+
# Fixed in: Laravel Reverb v1.11.0+
7+
8+
ROUTER_FILE="vendor/laravel/reverb/src/Servers/Reverb/Http/Router.php"
9+
10+
if [ -f "$ROUTER_FILE" ]; then
11+
echo "Patching Laravel Reverb Router..."
12+
13+
# Check if the file needs patching
14+
if grep -q "return \$request->getHeader('Upgrade')\[0\] ?? null === 'websocket';" "$ROUTER_FILE"; then
15+
# Apply the fix
16+
sed -i "s/return \\\$request->getHeader('Upgrade')\[0\] ?? null === 'websocket';/return (\\\$request->getHeader('Upgrade')\[0\] ?? null) === 'websocket';/" "$ROUTER_FILE"
17+
echo "✓ Reverb Router patched successfully"
18+
else
19+
echo "✓ Reverb Router already patched or not needed"
20+
fi
21+
else
22+
echo "✗ Reverb Router file not found (this is OK if Reverb is not installed)"
23+
fi

0 commit comments

Comments
 (0)