Skip to content

Commit

Permalink
[fix] Allow close code 1014 (#1682)
Browse files Browse the repository at this point in the history
  • Loading branch information
zed0 authored and lpinca committed Jan 21, 2020
1 parent 748a844 commit b6430fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ try {
exports.isValidStatusCode = (code) => {
return (
(code >= 1000 &&
code <= 1013 &&
code <= 1014 &&
code !== 1004 &&
code !== 1005 &&
code !== 1006) ||
Expand Down
13 changes: 13 additions & 0 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,19 @@ describe('WebSocket', () => {
wss.on('connection', (ws) => ws.close(1013));
});

it('allows close code 1014', (done) => {
const wss = new WebSocket.Server({ port: 0 }, () => {
const ws = new WebSocket(`ws://localhost:${wss.address().port}`);

ws.on('close', (code) => {
assert.strictEqual(code, 1014);
wss.close(done);
});
});

wss.on('connection', (ws) => ws.close(1014));
});

it('does nothing if `readyState` is `CLOSED`', (done) => {
const wss = new WebSocket.Server({ port: 0 }, () => {
const ws = new WebSocket(`ws://localhost:${wss.address().port}`);
Expand Down

0 comments on commit b6430fe

Please sign in to comment.