Add an onUploadHead hook so servers can attach headers to HEAD responses
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 64/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
Hướng nghiên cứu
The hook option belongs next to onUploadFinish in the server options/types, and the call site is HeadHandler.send in the head handler, after the lock is released and the Upload is loaded. Mirror how PatchHandler and PostHandler merge headers returned by onUploadFinish, then add the returned headers to the HEAD response. Done is a test that sets onUploadHead, performs a HEAD request and asserts the custom header, plus a case where a thrown error reaches onResponseError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Initial checklist
- I understand this is a feature request and questions should be posted in the Community Forum
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
onUploadFinish lets a server attach headers to the final PATCH or creation-with-upload POST response. We use it to return the id of the database row created for a completed upload, so clients can reference the stored object without a follow-up list call.
That contract has a hole on resume. When tus-js-client is given an uploadUrl or resumes from a stored fingerprint, it sends HEAD first, and if Upload-Offset already equals Upload-Length it fires onSuccess with the HEAD response as lastResponse and never issues a PATCH.
Any header added in onUploadFinish is therefore missing in exactly the cases where the client lost the final PATCH response or picks the upload up in a later session, and the client can't recover it from the TUS response.
Solution
No existing hook can see the HEAD response: onIncomingRequest runs before the upload is loaded, onResponseError only sees failures, and HeadHandler is not exported.
I would like to propose a hook that mirrors onUploadFinish, limited to headers since a HEAD response carries no body:
onUploadHead?: (
req: Request,
upload: Upload
) => Promise<{ headers?: Record<string, string | number> } | void>
HeadHandler.send would call it after the lock is released and the Upload has been loaded, merge any returned headers into the response the same way PatchHandler and PostHandler merge onUploadFinish headers, and let thrown errors propagate to onResponseError.
Passing the Upload lets a server decide from upload.offset === upload.size and upload.id instead of parsing its own response headers. The cost is zero when the option is unset.
Alternatives
Wrapping server.handlers.HEAD.send on the instance or bypassing handle() with handleWeb() plus the srvx/node adapters but hook approach is cleaner.
Related to https://github.com/tus/tusd/issues/1336, which suggests persisting state and replaying. That works in principal but not complete. For example, hook can cover more cases where state changes after finish such as ETag, expiry, permissions, deletes, etc.
Related to https://github.com/tus/tus-node-server/issues/714
- Ngôn ngữ chính
- TypeScript
- Star
- 1.1k
- Fork
- 228
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tus/tus-node-server
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
tus/tus-node-server#807 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Datastore dynamicĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tus/tus-node-server#737 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
tus/tus-node-server#722 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
tus/tus-node-server#521 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
tus/tus-node-server#380 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của tus/tus-node-server
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
awslabs/visual-asset-management-system#937 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
t0ggles
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
nolimits4web/swiper#8255 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 15 ngày
-
render: --variables-file (and --variables <path>) fails with "io.readFile is not a function" since 0.8.212Có thể đã có người làm @miguel-heygen đã nhận hôm nay. Đang mởbug triage/needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
heygen-com/hyperframes#6830 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug launch local use
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
account: profile bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 5 ngày