-
-
Notifications
You must be signed in to change notification settings - Fork 430
fix(hub): raise Socket.IO maxHttpBufferSize for file downloads #516
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,14 +20,15 @@ const jwtPayloadSchema = z.object({ | |
|
|
||
| const DEFAULT_IDLE_TIMEOUT_MS = 15 * 60_000 | ||
| const DEFAULT_MAX_TERMINALS = 4 | ||
| const DEFAULT_MAX_HTTP_BUFFER_SIZE = Math.ceil((50 * 1024 * 1024 * 4) / 3) | ||
|
|
||
| function resolveEnvNumber(name: string, fallback: number): number { | ||
| function resolveEnvNumber(name: string, fallback: number, max = fallback): number { | ||
| const raw = process.env[name] | ||
| if (!raw) { | ||
| return fallback | ||
| } | ||
| const parsed = Number.parseInt(raw, 10) | ||
| return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback | ||
| return Number.isFinite(parsed) && parsed > 0 ? Math.min(parsed, max) : fallback | ||
| } | ||
|
|
||
| export type SocketServerDeps = { | ||
|
|
@@ -63,6 +64,7 @@ export function createSocketServer(deps: SocketServerDeps): { | |
| const engine = new Engine({ | ||
| path: '/socket.io/', | ||
| cors: corsOptions, | ||
| maxHttpBufferSize: resolveEnvNumber('HAPI_SOCKET_MAX_BUFFER_SIZE', DEFAULT_MAX_HTTP_BUFFER_SIZE), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MAJOR] This raises the Engine.IO frame limit to 100 MiB before any namespace auth runs. We only need enough headroom for the existing 50 MiB file cap ( Suggested fix: const DEFAULT_MAX_HTTP_BUFFER_SIZE = Math.ceil((50 * 1024 * 1024 * 4) / 3)
function resolveEnvNumber(name: string, fallback: number, max = fallback): number {
const raw = process.env[name]
if (!raw) {
return fallback
}
const parsed = Number.parseInt(raw, 10)
return Number.isFinite(parsed) && parsed > 0 ? Math.min(parsed, max) : fallback
} |
||
| allowRequest: async (req) => { | ||
| const origin = req.headers.get('origin') | ||
| if (!origin || allowAllOrigins || corsOrigins.includes(origin)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MAJOR] This clamps every existing call to
resolveEnvNumberto its fallback becausemaxdefaults tofallback. The socket buffer needs that cap, but the same helper still feedsHAPI_TERMINAL_IDLE_TIMEOUT_MSandHAPI_TERMINAL_MAX_TERMINALS, so users can no longer raise the hub terminal idle timeout above 15 minutes or terminal count above 4.Suggested fix: