Skip to content

Fix crash in error event listener#2

Open
supermario wants to merge 1 commit into
masterfrom
fix/error-event-crash
Open

Fix crash in error event listener#2
supermario wants to merge 1 commit into
masterfrom
fix/error-event-crash

Conversation

@supermario
Copy link
Copy Markdown
Member

Summary

  • WebSocket error events are not CloseEvent objects — they don't have .code or .reason properties
  • The error listener in _LamderaWebsocket_listen passed event.code (undefined) to closedEvent, which crashed decodeCloseEventCode in the Elm runtime
  • Fix: use event.code || 1006 and event.reason || "" as fallbacks — 1006 (AbnormalClosure) is the correct semantic code for connection errors
  • Added 14 Kernel JS unit tests with mock WebSocket and Elm runtime stubs
  • Added GitHub Actions CI

Test plan

  • All 14 kernel tests pass locally (node --test test/kernel-test.mjs)
  • CI passes on PR
  • Deploy to production and verify no more "Exception in _LamderaWebsocket_listen error listener" logs

WebSocket error events are not CloseEvents and don't have .code/.reason
properties. Accessing undefined values crashed decodeCloseEventCode in
the Elm runtime. Use 1006 (AbnormalClosure) as the fallback, which is
the correct semantic code for connection errors.

Also adds Kernel JS tests and GitHub CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant