-
-
Notifications
You must be signed in to change notification settings - Fork 671
feat: implement WebSocketStream #3560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
44cd930
start
KhafraDev 5eb9372
fixup
KhafraDev 86b4922
fixup
KhafraDev 5baedea
fixup
KhafraDev 64e3c8a
run wpts
KhafraDev f3a3d8b
fix 49 errors
KhafraDev 89b71f6
fix 49 errors
KhafraDev 4abc633
fix 7 errors
KhafraDev 8d78080
fix 12 failures
KhafraDev fa6c8dd
fix 10 failures
KhafraDev fccad1f
fixup
KhafraDev 43a9b8d
fix 9 failures
KhafraDev 7586cc2
fix 3 failures
KhafraDev a42ae7b
fix 3 failures
KhafraDev 1237174
fix rest of failures
KhafraDev 7d0554b
fixup
KhafraDev e3e1818
mark timing test as flaky
KhafraDev 55cf4de
spell
KhafraDev 2f37e60
fixup
KhafraDev d45cac7
Merge branch 'main' into websocketstream-again
KhafraDev 1d8507a
fixup
KhafraDev a64328a
run the CI again! woo!
KhafraDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| 'use strict' | ||
|
|
||
| const { webidl } = require('../../fetch/webidl') | ||
| const { validateCloseCodeAndReason } = require('../util') | ||
| const { kConstruct } = require('../../../core/symbols') | ||
|
|
||
| class WebSocketError extends DOMException { | ||
| #closeCode | ||
| #reason | ||
|
|
||
| constructor (message = '', init = undefined) { | ||
| message = webidl.converters.DOMString(message, 'WebSocketError', 'message') | ||
|
|
||
| // 1. Set this 's name to " WebSocketError ". | ||
| // 2. Set this 's message to message . | ||
| super(message, 'WebSocketError') | ||
Uzlopak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (init === kConstruct) { | ||
| return | ||
| } else if (init !== null) { | ||
| init = webidl.converters.WebSocketCloseInfo(init) | ||
| } | ||
|
|
||
| // 3. Let code be init [" closeCode "] if it exists , or null otherwise. | ||
| let code = init.closeCode ?? null | ||
|
|
||
| // 4. Let reason be init [" reason "] if it exists , or the empty string otherwise. | ||
| const reason = init.reason ?? '' | ||
|
|
||
| // 5. Validate close code and reason with code and reason . | ||
| validateCloseCodeAndReason(code, reason) | ||
|
|
||
| // 6. If reason is non-empty, but code is not set, then set code to 1000 ("Normal Closure"). | ||
| if (reason.length !== 0 && code === null) { | ||
| code = 1000 | ||
| } | ||
|
|
||
| // 7. Set this 's closeCode to code . | ||
| this.#closeCode = code | ||
|
|
||
| // 8. Set this 's reason to reason . | ||
| this.#reason = reason | ||
| } | ||
|
|
||
| get closeCode () { | ||
| return this.#closeCode | ||
| } | ||
|
|
||
| get reason () { | ||
| return this.#reason | ||
| } | ||
|
|
||
| /** | ||
| * @param {string} message | ||
| * @param {number|null} code | ||
| * @param {string} reason | ||
KhafraDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| static createUnvalidatedWebSocketError (message, code, reason) { | ||
Uzlopak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const error = new WebSocketError(message, kConstruct) | ||
| error.#closeCode = code | ||
| error.#reason = reason | ||
| return error | ||
| } | ||
| } | ||
|
|
||
| const { createUnvalidatedWebSocketError } = WebSocketError | ||
| delete WebSocketError.createUnvalidatedWebSocketError | ||
|
|
||
| module.exports = { WebSocketError, createUnvalidatedWebSocketError } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.