Commit Graph

60 Commits

Author SHA1 Message Date
Fabian @ Blax Software fa32057035 fix(server): reliably reap fork-per-message child processes (zombie leak)
The fork-per-message model spawns a child per inbound message; each child
exit(0)s when done. The only reaper was a single, non-looping
pcntl_waitpid(-1, WNOHANG) inside the IPC onClose callback — which fires on
socket EOF, an event that routinely precedes the child's actual process exit,
so it frequently reaped nothing and left <defunct> zombies parented to the
live serve process (where no PID 1 init can reach them). Under sustained
traffic these accumulated until pcntl_fork() itself failed.

- Handler::onClose now drains ALL exited children in a loop (was a single
  wait). activeChildCount bookkeeping stays per-socket, untouched.
- StartServer adds a SIGCHLD handler + a 10s periodic backstop (catches
  children that crashed before IPC setup, so no onClose fires) + a
  drain-on-shutdown so a deploy restart does not hand orphans to PID 1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 11:06:54 +02:00
Fabian @ Blax Software a0d4699cdf fix(handler): improve exception reporting to Sentry by honoring application's report policy 2026-06-17 13:39:08 +02:00
Fabian @ Blax Software dd6be893a6 BF cache-key slug drift on ws_socket_auth_*; resilient User column in watch -v
Handler::cacheAuthenticatedUser() and ::cleanupChannelConnections() were
writing/forgetting ws_socket_auth_<rawSocketId> while
WebsocketService::getAuth() and ::setUserAuthed() have always slugged
("123.456" → "123-456"). Result: the cache write was reachable from the
package's own writer path but not from the service-layer reader, so the
admin tooling (websockets:watch -v) saw cache misses and rendered #<id>
instead of the configured IdentityFormatter output.

Also: WatchStats now batch-loads missing users via the configured auth
provider model in one query per render, so the User column still renders
the full formatter shape even when the per-socket cache blob predates
the writer or got evicted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 13:56:07 +02:00
Fabian @ Blax Software e45d8dff20 F websockets:watch -v — per-connection rows (socket id, user, duration)
Verbose mode reuses Symfony's built-in -v flag (the short option is
reserved, so a custom one can't be added). Each channel summary is
followed by sub-rows showing the socket id, the authed user (falling
back to "Guest" or the user id if the user blob expired), and how long
the connection has been open.

Connection start times are written by Handler::establishConnection() into
ws_connection_<slug(socketId)> on open and forgotten on close. Also
fixed a latent bug in finalizeConnectionClose() where the forget key was
missing the slug() call that the reader has always used — previously
invisible because nothing wrote the key, now load-bearing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 13:42:26 +02:00
Fabian @ Blax Software 2ad8d490b7 fix: harden IPC callbacks and decouple auth lookup via configurable resolver 2026-04-17 11:03:02 +02:00
Fabian @ Blax Software ed371ac051 fix: catch Throwable in fork child, protect class_exists in scanning 2026-04-16 09:24:11 +02:00
Fabian @ Blax Software 093bbe3a44 A tests, documentation for helpers and lifecycle
- Introduced `helpers-and-testing.md` to document global helpers and WebsocketService class usage.
- Created `HandlerLifecycleTest.php` to test the full WebSocket handler lifecycle, including connection management, channel subscriptions, and message routing.
- Added `WebsocketServiceTest.php` to validate state tracking methods in WebsocketService, covering user authentication, channel tracking, and broadcast functionality.
2026-04-02 12:44:16 +02:00
Fabian @ Blax Software 77e12db729 BF long lasting subscription 2026-03-27 09:38:07 +01:00
Fabian @ Blax Software 7dd2df48d1 I DB connecting & auth handling 2026-03-23 14:13:30 +01:00
Fabian @ Blax Software c77eec57c1 I sentry reporting 2026-03-23 10:15:45 +01:00
Fabian @ Blax Software 0757e6d9f9 I stability 2026-03-21 12:56:50 +01:00
Fabian @ Blax Software f191c44634 BF pong 2026-03-21 10:27:03 +01:00
Fabian @ Blax Software d091ebbd82 I last ponged timestamp 2026-03-21 10:01:10 +01:00
Fabian @ Blax Software 35b2731349 I max concurrency handling, BF restart 2026-03-20 13:44:51 +01:00
Fabian @ Blax Software 636d9eccb8 I parent connection states 2026-03-05 12:26:56 +01:00
Fabian @ Blax Software 2a47591907 R cache, connection session, performance 2026-02-09 13:50:42 +01:00
Fabian @ Blax Software 7c1fca5c38 R performance improvements 2026-02-09 13:19:09 +01:00
Fabian @ Blax Software 1eafa237a0 R removed polling, transitioned to kernel events 2026-02-09 13:04:22 +01:00
Fabian @ Blax Software 986ce76fb7 IA hotreloads 2026-02-02 13:20:39 +01:00
Fabian @ Blax Software f7e08a337b BF whisper, broadcast 2026-02-02 11:24:54 +01:00
Fabian @ Blax Software 2849f0fe5f RI websocket performance 2026-01-24 14:42:35 +01:00
Fabian @ Blax Software 5b8a2a8112 I performance, A testing & event-driven 2026-01-24 13:34:29 +01:00
Fabian @ Blax Software 6ce8573fed RI websocket performance, BF race condition 2026-01-24 12:17:46 +01:00
a6a2f5842 ad0e8d556f I cache latency 2025-12-05 21:48:23 +01:00
a6a2f5842 21037b617b R handler 2025-12-05 20:53:52 +01:00
a6a2f5842 55c819700b A default broadcasting route, I ip on close 2025-12-05 19:56:44 +01:00
a6a2f5842 6776d3c5c2 A sentry capture 2025-12-02 18:33:52 +01:00
a6a2f5842 f5df27f96a BF auth state 2025-10-15 10:32:35 +02:00
a6a2f5842 5eba7e19ff BF type 2025-10-15 09:45:04 +02:00
a6a2f5842 447cc71256 I auth state 2025-10-15 09:35:07 +02:00
a6a2f5842 dcf8315290 I auth state 2025-10-15 09:27:37 +02:00
a6a2f5842 2aa264eb34 BF queue dispatch 2025-09-19 12:18:40 +02:00
a6a2f5842 2960c3a3f3 BF edgecase 2025-09-18 18:07:15 +02:00
a6a2f5842 4155e05d76 BF has connection on null 2025-09-18 17:55:52 +02:00
a6a2f5842 5284e7fd2f I presence subscription 2025-09-18 15:56:13 +02:00
a6a2f5842 5607969ae1 BF unsubscribing 2025-09-16 13:39:48 +02:00
a6a2f5842 741cffe03a BF unsubscribe 2025-09-16 11:20:48 +02:00
a6a2f5842 c38e8fc082 BF broadcast 2025-09-16 10:58:54 +02:00
a6a2f5842 df349aabf7 BF subscribe & I logging 2025-09-16 08:54:13 +02:00
a6a2f5842 a6ff330e57 BF pinging 2025-09-15 16:31:02 +02:00
a6a2f5842 fc23dff3d9 BF channel subscription 2025-09-15 16:22:59 +02:00
a6a2f5842 69584c8fe2 A whisper 2025-09-15 14:29:07 +02:00
a6a2f5842 5bd6cf2341 I auth storage 2025-09-15 10:20:13 +02:00
a6a2f5842 bc6abf6841 I support default Channel 2025-09-14 15:00:27 +02:00
a6a2f5842 6031cdf9c5 BF broadcasting 2025-09-13 19:48:59 +02:00
a6a2f5842 5c7d6a1c1b A broadcasting 2025-09-13 19:33:29 +02:00
a6a2f5842 4fe731a777 BF catch throwable instead of exceptions 2025-09-06 10:43:07 +02:00
a6a2f5842 f5470c9b0a IA support defer() method 2025-09-01 14:16:30 +02:00
a6a2f5842 9e85f2c457 I better error display 2025-06-13 10:31:59 +02:00
a6a2f5842 4f0dd41028 I added better error display 2025-06-12 16:16:07 +02:00