Skip to content

Export constants for ReadyState in websockets module - #6306

Merged
janHildebrandt98 merged 3 commits into
masterfrom
fix/web-socket-typedefs
Aug 25, 2026
Merged

janHildebrandt98 merged 3 commits into
masterfrom
fix/web-socket-typedefs

Conversation

@janHildebrandt98

@janHildebrandt98 janHildebrandt98 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

What?

Exports constants for the ReadyState values on both WebSocket constructor and instances following the spec.

Why?

Replaces the previously, wrongly advertised (by the typedefs) enum.
Aligns our implementation with what user are used to from the browser.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Related PR(s)/Issue(s)

PR in grafana/k6-DefinitelyTyped: grafana/k6-DefinitelyTyped#120

Issue was also described in #4540

@janHildebrandt98
janHildebrandt98 requested a review from a team as a code owner August 17, 2026 10:14
@janHildebrandt98
janHildebrandt98 requested review from ankur22 and joanlopez and removed request for a team August 17, 2026 10:14
@janHildebrandt98 janHildebrandt98 changed the title Fix/web socket typedefs Export constants for ReadyState in websockets module Aug 17, 2026
@janHildebrandt98
janHildebrandt98 temporarily deployed to azure-trusted-signing August 17, 2026 10:27 — with GitHub Actions Inactive
@janHildebrandt98
janHildebrandt98 temporarily deployed to azure-trusted-signing August 17, 2026 10:29 — with GitHub Actions Inactive

@ankur22 ankur22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ๐Ÿš€

Nit: is there no way to test the closing state in the test?

@janHildebrandt98

Copy link
Copy Markdown
Contributor Author

LGTM ๐Ÿš€

Nit: is there no way to test the closing state in the test?

Not sure what you mean :) But I though the existing tests were sufficient. I changed them to use the new constants so we ensure the constants actually work as well

@janHildebrandt98
janHildebrandt98 merged commit 6b9cbaa into master Aug 25, 2026
57 of 59 checks passed
@janHildebrandt98
janHildebrandt98 deleted the fix/web-socket-typedefs branch August 25, 2026 12:33
@inancgumus inancgumus added this to the v2.3.0 milestone Sep 10, 2026
inancgumus added a commit to grafana/k6-docs that referenced this pull request Sep 16, 2026
* docs: add WebSocket ready-state documentation

Adds connection-state constants and an example for checking them.

Related: grafana/k6#6306

* docs: clarify WebSocket state comparisons

Direct users to browser-compatible constants instead of a runtime enum\nthat k6 does not export.

* docs: remove unused WebSocket enum guidance

Keep connection-state guidance focused on the supported constants.

This branch was previously deployed

1 inactive deployment
azure-trusted-signing โ€” 23964109 Deployed Aug 17, 2026 by janHildebrandt98 via sign-packages #10371
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.

4 participants