Defjs
Core

HttpProgressFn

Callback invoked as request bytes are uploaded or response bytes are downloaded.

@defjs/core · Type

Signature

type HttpProgressFn = (event: HttpProgressEvent) => Promise<void> | void;

Passed as onDownloadProgress or onUploadProgress in HttpExecuteOptions. Callbacks may be async and are awaited before the next chunk is processed. A callback that throws or rejects fails the call with EXT_OBSERVER_FAILED, with the thrown value as cause, for downloads and uploads alike. Caller cancellation still takes precedence and reports NET_ABORTED, or NET_TIMEOUT when the abort reason is a timeout.

Upload progress for a Blob, File, ArrayBuffer, or FormData body is reported only where the runtime can stream request bodies (Bun, Node). In browsers that body is sent unchanged and onUploadProgress is not called. A caller-supplied ReadableStream still reports progress wherever the runtime accepts it. Download progress is unaffected.

On server runtimes, FormData with onUploadProgress reads its serialized stream directly, keeps its multipart boundary, and is sent without a library-generated Content-Length (chunked over HTTP/1.1), so progress and abort work without buffering the whole body. It reports an unknown total unless a valid explicit Content-Length supplies it. For an endpoint that requires Content-Length, such as some presigned upload targets, omit onUploadProgress; platform Fetch then sends FormData with its length. Non-identity encoded downloads also report total: 0 and lengthComputable: false, since loaded counts decoded stream bytes. Cancellation releases the wrapped upload stream.

Parameters

Prop

Type

event HttpProgressEvent
Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao