Fix Storage Emulator JSON upload limit and body parsing hangs#10800
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
There was a problem hiding this comment.
Code Review
This pull request increases the request body size limit to 130MB for various storage emulator endpoints (both Firebase and GCloud APIs) to handle large uploads and JSON payloads, addressing issue #8355. It introduces custom upload middlewares to conditionally apply the larger limits and removes the global JSON parser in favor of route-specific parsers. Feedback suggests removing a redundant ?.toString() call on req.header() since Express already returns a string or undefined.
| return json({ limit: "130mb" })(req, res, next); | ||
| } | ||
|
|
||
| const uploadType = req.header("x-goog-upload-protocol")?.toString(); |
There was a problem hiding this comment.
There was a problem hiding this comment.
Agreed - this is uneceesary
| import { reqBodyToBuffer } from "../../shared/request"; | ||
| import type { Query } from "express-serve-static-core"; | ||
|
|
||
| /** |
There was a problem hiding this comment.
LGTM!
tested against https://github.com/aalej/issues-8355 - works
tested file uploads via console(emulator ui) - works
- images
- files with special chars on name
- json files
- multiple file upload
tested curl uploads - works
| expect(String(data)).to.eql("hello world"); | ||
| }); | ||
|
|
||
| it("should handle large JSON uploads (issue #8355)", async () => { |
There was a problem hiding this comment.
No need to mention the issue number here.
Addresses issue #8355. Fixes the Storage Emulator to handle large JSON uploads without throwing 413 or hanging due to eager body parsing.