Move MAX_MESSAGE_SIZE assertion

This commit is contained in:
Evan Hahn 2021-09-10 15:16:53 -05:00 committed by GitHub
parent 57c41ad5f1
commit 4ef56667e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,6 +188,10 @@ export default class WebSocketResource extends EventTarget {
id,
},
}).finish();
strictAssert(
bytes.length <= MAX_MESSAGE_SIZE,
'WebSocket request byte size exceeded'
);
strictAssert(!this.shuttingDown, 'Cannot send request, shutting down');
this.addActive(id);
@ -210,10 +214,6 @@ export default class WebSocketResource extends EventTarget {
});
});
strictAssert(
bytes.length <= MAX_MESSAGE_SIZE,
'WebSocket request byte size exceeded'
);
this.socket.sendBytes(Buffer.from(bytes));
return promise;