Skip to content
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

Autobahn suite #3251

Merged
merged 9 commits into from
May 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix error message in websocket
  • Loading branch information
KhafraDev committed May 12, 2024
commit c6f70a52f7aa6e008676a10f67f119b823e2a077
16 changes: 13 additions & 3 deletions lib/web/websocket/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const { ByteParser } = require('./receiver')
const { kEnumerableProperty, isBlobLike } = require('../../core/util')
const { getGlobalDispatcher } = require('../../global')
const { types } = require('node:util')
const { ErrorEvent } = require('./events')
const { ErrorEvent, CloseEvent } = require('./events')

let experimentalWarned = false

Expand Down Expand Up @@ -594,9 +594,19 @@ function onParserDrain () {
}

function onParserError (err) {
fireEvent('error', this, () => new ErrorEvent('error', { error: err, message: err.reason }))
let message
let code

if (err instanceof CloseEvent) {
message = err.reason
code = err.code
} else {
message = err.message
}

fireEvent('error', this, () => new ErrorEvent('error', { error: err, message }))

closeWebSocketConnection(this, err.code)
closeWebSocketConnection(this, code)
}

module.exports = {
Expand Down
Loading