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

Add WebSocket support (ws) #270

Open
wants to merge 27 commits into
base: beta
Choose a base branch
from
Open

Add WebSocket support (ws) #270

wants to merge 27 commits into from

Conversation

timokoessler
Copy link
Contributor

@timokoessler timokoessler commented Jul 5, 2024

Copy link

codecov bot commented Jul 5, 2024

sample-apps/ws-postgres/app.js Dismissed Show dismissed Hide dismissed
sample-apps/ws-postgres/app.js Fixed Show fixed Hide fixed
sample-apps/ws-postgres/app.js Dismissed Show dismissed Hide dismissed
sample-apps/ws-postgres/app.js Dismissed Show dismissed Hide dismissed
@timokoessler timokoessler changed the title Add WebSocket support (WIP) Add WebSocket support (ws) Jul 15, 2024
@timokoessler timokoessler marked this pull request as ready for review July 15, 2024 10:06

export function getMaxWsMsgSize() {
if (process.env.AIKIDO_MAX_WS_MSG_SIZE_MB) {
const parsed = parseInt(process.env.AIKIDO_MAX_WS_MSG_SIZE_MB, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

let's reuse

export function getMaxBodySize() {

return;
}
} catch (e) {
// Ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

this is dangerous, lets log at least

} // Handle ArrayBuffer or Buffer
else if (Buffer.isBuffer(data) || data instanceof ArrayBuffer) {
const decoder = new TextDecoder("utf-8", {
fatal: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

can you comment what this means?


const result = shouldRateLimitRequest(context, agent);
if (result.block) {
let message = "You are rate limited by Aikido firewall.";
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this for now

"WebSocket message size exceeded the maximum allowed size. Use AIKIDO_MAX_BODY_SIZE_MB to increase the limit."
);
// Closing does not prevent the regular onMessage event from firing
socket.terminate();
Copy link
Contributor

Choose a reason for hiding this comment

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

should we close it?

return Array.isArray(data) && data.every((d) => Buffer.isBuffer(d));
}

function checkWsDataSize(data: WsData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

naming suggestion-: isMessageDataTooLarge

@timokoessler timokoessler changed the base branch from main to beta November 25, 2024 16:49
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.

2 participants