fix(ws): allow ws.once() to work multiple times

Merged
RO
10mo ago
+225-2

Summary

  • Fixes ws.once() only working on the first call for each event type
  • The bug was in the #onOrOnce method which tracked native listeners via a bitset but didn't account for once listeners auto-removing after firing
  • Now only persistent on() listeners set the bitset; once() listeners always add new native handlers unless a persistent listener already exists

Test plan

  • Added regression test test/regression/issue/26358.test.ts
  • Test verifies once('message') works multiple times
  • Test verifies once('pong') works multiple times
  • Test verifies on() still works correctly
  • Test verifies mixing on() and once() works correctly
  • Verified test fails with USE_SYSTEM_BUN=1 (bug exists)
  • Verified test passes with bun bd test (fix works)

Fixes #26358

šŸ¤– Generated with Claude Code