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

Bypass nginx proxy buffering when uploading roms #1201

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions backend/endpoints/responses/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,19 @@ class SimpleRomSchema(RomSchema):
rom_user: RomUserSchema

@classmethod
def from_orm_with_request(
cls, db_rom: Rom, request: Request
) -> SimpleRomSchema | None:
def from_orm_with_request(cls, db_rom: Rom, request: Request) -> SimpleRomSchema:
user_id = request.user.id

db_rom.rom_user = RomUserSchema.for_user(user_id, db_rom)

return cls.model_validate(db_rom)

@classmethod
def from_orm_with_factory(cls, db_rom: Rom) -> SimpleRomSchema:
db_rom.rom_user = rom_user_schema_factory()

return cls.model_validate(db_rom)


class DetailedRomSchema(RomSchema):
merged_screenshots: list[str]
Expand Down
2 changes: 1 addition & 1 deletion backend/endpoints/sockets/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async def _identify_rom(
{
"platform_name": platform.name,
"platform_slug": platform.slug,
**SimpleRomSchema.model_validate(_added_rom).model_dump(
**SimpleRomSchema.from_orm_with_factory(_added_rom).model_dump(
exclude={"created_at", "updated_at", "rom_user"}
),
},
Expand Down
7 changes: 5 additions & 2 deletions docker/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ http {
client_max_body_size 0;
client_header_buffer_size 1k;
large_client_header_buffers 4 16k;
send_timeout 60s;
keepalive_timeout 65s;
send_timeout 600s;
keepalive_timeout 600s;
client_body_timeout 600s;
tcp_nopush on;
tcp_nodelay on;

Expand Down Expand Up @@ -97,6 +98,8 @@ http {
# Backend api calls
location /api {
proxy_pass http://wsgi_server;
proxy_request_buffering off;
proxy_buffering off;
}
location /ws {
proxy_pass http://wsgi_server;
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/services/api/rom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ async function uploadRoms({
api
.post("/roms", formData, {
headers: {
"Content-Type": "multipart/form-data; boundary=boundary",
"Content-Type": "multipart/form-data",
"X-Upload-Platform": platformId.toString(),
"X-Upload-Filename": file.name,
},
timeout: 600000,
params: {},
onUploadProgress: (progressEvent: AxiosProgressEvent) => {
uploadStore.update(file.name, progressEvent);
Expand Down
Loading