Skip to content

πŸ› Bug Report β€” WebSocket constructor throws SyntaxError error when protocols array is emptyΒ #5822

@volkanunsal

Description

@volkanunsal

https://github.com/cloudflare/workerd/blame/39fb8495e5a4a700ccfdf2ec5e201fd590be046e/src/workerd/api/web-socket.c%2B%2B#L228

This is causing problems for us using WebSocket API. The web standard doesn't throw a SyntaxError when protocols array is empty, and I've been relying on this functionality in a project, which currently cannot be deployed to Cloudflare platform because we're getting this error:

✘ [ERROR] XXX: Error creating WebSocket instance: DOMException {

    code: 12,
    name: 'SyntaxError',
    message: 'WebSocket Constructor: The protocols array cannot be empty.',
    stack: 'SyntaxError: WebSocket Constructor: The protocols array cannot be empty.\n' +
      '    at null.<anonymous>
  }

Please advise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions