fields-media-multipart: JPEG uploads fail with "Corrupt JPG, exceeded buffer limits" when the upload arrives in pieces
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- graphql, node.js, typescript
Research direction
Start in the @keystone-6/fields-media-multipart upload field, where image dimensions are read from the upload stream, and trace how the size-parsing and storage streams are coordinated. Reproduce with a JPEG whose SOF marker is beyond the first 1,024 bytes, delivered in chunks. Done when chunked JPEG uploads store successfully with width and height, without causing other uploads to hang.
Written by the indexing model from the issue text.
Description
Steps to reproduce
- In a project on the published packages (
@keystone-6/core9.0.0,@keystone-6/fields-media-multipart1.0.0), withexamples/assets-local'sPostlist. Pinimage-sizeto 2.1.0 to get past the other upload failure (view.u16be is not a function, see #10141). - Upload a JPEG whose size marker (SOF) comes after the first kilobyte, over a connection that delivers the request body in pieces. Most JPEGs from cameras and phones qualify: their Exif, ICC profile and thumbnail segments come before SOF. Even a small JPEG converted with macOS's
sipshas SOF0 at byte 4,670, behind its ICC profile.
Sending the same multipart request in one piece and in 1,460-byte pieces 5 ms apart gives:
| Upload | Result |
|---|---|
| PNG, in one piece | stored |
| JPEG, in one piece | stored |
| the same JPEG, in 1,460-byte pieces | Post.banner: Corrupt JPG, exceeded buffer limits |
On localhost an upload usually arrives in one piece, which hides the failure; on a slow or mobile connection it doesn't.
Expected
The JPEG is stored with its width and height, however the request body arrives.
Cause
The field parses the size from the first 1,024 bytes of the upload's stream, and while the request body is still arriving that is all the stream holds; a JPEG's SOF usually lies further in, so image-size throws. Keystone 6's image field read the whole upload first.
Reading further from the same stream makes things worse: it is teed with the storage branch, which is not read until the size is known, so once that branch's buffer is full the source pauses and the read waits forever (we saw a large non-image hold the request open). Reading the size from a second upload.createReadStream(), which starts its own stream from the beginning, avoids that.
Context
Node 24.18.0, macOS; @keystone-6/core 9.0.0, @keystone-6/fields-media-multipart 1.0.0, graphql-upload 17.1.0, image-size 2.1.0.
- Dominant language
- TypeScript
- Stars
- 10k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 38
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from keystonejs/keystone
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
keystonejs/keystone#10143 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
keystonejs/keystone#10141 ·
Maintainers usually reply within 1 day
-
[bug] List view search field becomes disabled when search returns no results, interrupting IME inputPossibly taken @ltxhhz claimed this 17 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
keystonejs/keystone#10097 ·
Maintainers usually reply within 1 day
-
Document Fields Demo page of docs refers to form that doesn't existMay be free again @Mthize claimed this 189 days ago, and no pull request is open. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
keystonejs/keystone#9766 · 1 comment ·
Maintainers usually reply within 1 day
-
bigInt field defaultValue { kind: 'autoincrement' } triggers missing value validationMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
keystonejs/keystone#10048 ·
Maintainers usually reply within 1 day
All issues in keystonejs/keystone
Similar issues
-
Media browser returns "Not found" for repositories using the SHA-256 object formatPossibly taken @adamchodera claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Follow-ups from #312Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
janhesters/remixcn#318 ·
Maintainers usually reply within 1 day
-
Interceptor LaunchTestProfile.sh: no Windows (Git Bash/MSYS) branch, test profile never launchesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
danielmiessler/LifeOS#3150 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Make the "%" unit spacing the same in the web and in A10Possibly taken @kragent66-glitch claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 comment ·