Skip to content

Errors ​

This page lists every error Hyper Compress can return, on every surface, and what to do about each. An error means you got no output file. When Hyper skips an option instead, that is a warning, not an error.

For patterns that handle errors, timeouts and cancellation in an app or service, see Errors, timeouts and cancellation.

Error codes ​

The CLI, the Node.js SDK, the Rust crate, the HTTP API and WebAssembly share four codes:

CodeMeaningWhat to do
decrypt_failedThe password is wrong, or the PDF needs a password and none was given.Ask for the password. Check it first with verifyPassword. See Encrypted PDFs.
engine_errorHyper could not run: no engine for this platform, an engine path that does not exist, an empty input path, input that is not a PDF, a file that cannot be read or written, a missing qpdf when a password is given, or a failure inside the engine.Read the message. It names the platform, the path or the file problem. See Troubleshooting.
timeoutOne step ran past the per-step limit (timeoutMs, stage_timeout, or the HTTP service's HYPER_TIMEOUT_MS; 10 minutes by default), or the whole call ran past its total limit (totalTimeoutMs, total_timeout, HYPER_TIMEOUT_MS).Raise the limit, or use a lighter preset. Large scans with a size target take longest.
cancelledYou cancelled the call (AbortSignal in Node.js, CancelToken in Rust).Nothing; this is the result you asked for.

These are not errors, and return a result instead:

SituationWhat you get
Hyper could not make the file smallerYour original bytes, output size equal to input size.
The input is digitally signedYour original bytes, signed: true.
A size target was missedThe smallest file Hyper made, metTarget: false, a warning.
An option was unsafe for this fileA warning.
A PDF with only an owner password (it opens without one) and no password givenA compressed file that keeps the owner password.

Node.js SDK ​

Every error is a HyperError with code set to one of the error codes. See Node.js SDK.

CodeMessageCause
engine_errorsourcePath is requiredsourcePath is empty or missing.
engine_errorno hpdf-worker binary for <platform>: use a platform with a native package (darwin-arm64, linux-x64, linux-arm64, win32-x64), set HYPER_DRV to a binary you built (see BUILDING.md), or switch to the hyper-compress-wasm packageNo engine found. <platform> is for example linux-x64 or darwin-arm64.
engine_errorno hyper-compress.node binary for <platform>: ... (same text, naming HYPER_ADDON)No native addon found.
engine_errorno qpdf binary for <platform>: ... (same text, naming HYPER_QPDF)A password was given and qpdf was not found. Also from verifyPassword.
engine_errorhpdf-worker not found at <path>HYPER_DRV points to a file that does not exist.
engine_errorqpdf not found at <path>HYPER_QPDF points to a file that does not exist.
engine_errorcannot read <path>: <reason>The input cannot be read, for example No such file or directory (os error 2). From verifyPassword: cannot read <path>.
engine_errorthe input is not a PDF: no %PDF- header in its first 1024 bytesThe input is not a PDF.
engine_errorAn operating system message, for example Permission denied (os error 13)The output, report or a temporary file cannot be written.
decrypt_faileddecrypt_failedWrong password.
decrypt_failedthe PDF is encrypted and needs a passwordThe PDF needs a password and password was not given.
timeoutthe engine pass ran longer than the <n> ms stage limit (also decryption ... and qpdf ...)One step ran past timeoutMs.
timeouttimeoutThe call ran past totalTimeoutMs. Or the AbortSignal reason was a HyperError with this code.
cancelledcancelledThe AbortSignal fired. If the abort reason is a HyperError, you get that error instead.

An addon that exists but cannot be loaded (for example, built for another platform) throws Node.js's own loader error, not a HyperError.

verifyPassword returns false rather than an error for a wrong password and for a file that exists but is not a PDF. It throws engine_error for a missing file and timeout for a check that runs too long.

CLI ​

Exit codeMeaningstderr
0Success, including original kept, signed input and missed target.Warnings, if any
1The compression failed.error: <message>, where the message is one of the Node.js SDK messages (from the Rust core).
2Bad usage.error: <message>, the usage text, and run "hyper --help" for the full option list

Usage messages (exit 2):

MessageWhat to do
an input PDF is requiredPass an input path.
--preset expects one of low, medium, high, losslessUse one of those names.
--mrc expects off, auto or forceUse one of those modes.
--target-size expects a size like 2MB, 500KB or a byte countUse a number with B, K, KB, M or MB.
--target-size must be greater than zeroUse a size of at least 1 byte.
--report expects a file pathPut a path after --report.
--set expects key=valueWrite --set name=value.
unknown flag <flag>Check the spelling; hyper --help lists every flag.

The CLI has no total time limit and no cancellation, but each step is limited to 10 minutes, so it can fail with error: the engine pass ran longer than the 600000 ms stage limit. See CLI.

Rust crate ​

compress and verify_password return Err(HyperError) with code: ErrorCode and message: String:

ErrorCodeas_str()Messages
DecryptFaileddecrypt_faileddecrypt_failed, the PDF is encrypted and needs a password
EngineErrorengine_errorsourcePath is required, no hpdf-worker binary for <platform>: ..., no qpdf binary for <platform>: ..., hpdf-worker not found at <path>, qpdf not found at <path>, cannot read <path>: <reason>, the input is not a PDF: no %PDF- header in its first 1024 bytes, or an operating system message
Timeouttimeoutthe engine pass ran longer than the <n> ms stage limit (also decryption ..., qpdf ...), or timeout for total_timeout
Cancelledcancelledcancelled

<platform> is spelled the way npm spells it: darwin-arm64, linux-x64, linux-arm64 or win32-x64. See Rust crate.

WebAssembly ​

CodeMessageCause
decrypt_failedwrong or missing passwordThe password is wrong.
decrypt_failedthe PDF is encrypted and needs a passwordThe PDF needs a password and none was given.
engine_errorthe input is not a PDF: no %PDF- header in its first 1024 bytesThe input is not a PDF.
engine_errorwasm module failed to load: <reason>The engine files could not be loaded. The next call tries again.
engine_errorThe underlying error's messageSomething failed inside the engine, for example running out of memory.

The WebAssembly package never produces timeout or cancelled. See WebAssembly.

HTTP API ​

Errors are JSON bodies with an error code, sometimes with extra fields. See HTTP API.

json
{ "error": "too_large", "maxBytes": 524288000 }
StatuserrorExtra fieldsCauseWhat to do
400bad_presetpresets: ["low", "medium", "high", "lossless", "custom"]preset is not one of those names.Use a listed preset.
400options_requiredpreset=custom without an options parameter.Send options with custom.
400bad_optionsoptions is not a JSON object, or is longer than 4096 characters.Send a URL-encoded JSON object.
400bad_target_sizetargetSizeBytes is not a number greater than 0.Send a positive byte count.
400not_a_pdfThe body is shorter than 5 bytes or does not start with %PDF.Send the PDF bytes as the raw body, not as a form upload.
400decrypt_failedThe password (X-Password or X-Password-Encoded) is wrong, or the PDF needs a password and none was sent.Send the right password. Check it with /api/verify-password. Send non-ASCII passwords in X-Password-Encoded.
401unauthorizedHYPER_API_TOKEN is set and the request has no matching Authorization: Bearer or X-Api-Token header.Send the token.
404not_foundUnknown path or method, or a missing static file.Check the URL and method.
413too_largemaxBytes: the limit in bytesThe body is larger than HYPER_MAX_UPLOAD_MB.Send a smaller file, or raise the limit.
429busydetail: "queue full, retry later"; header Retry-After: 1Every slot is busy and the queue (HYPER_QUEUE) is full.Retry after the Retry-After delay, with backoff.
500engine_errorThe engine failed, or no engine binary was found.Check the service logs and the file.
500cancelledMapped for completeness. The service does not cancel requests, so this does not occur.
500internalA temporary file could not be written or read, or /api/verify-password failed for any reason.Check disk space and the temp folder; retry.
504timeoutOne step, or the whole request, ran past HYPER_TIMEOUT_MS (default 10 minutes).Raise HYPER_TIMEOUT_MS, or send lighter settings.

/api/verify-password answers 200 {"valid": false} for a wrong password, not an error. It can return 401, 413, 429 and 500 internal.

Checks run in this order: authentication, preset, targetSizeBytes, options, the queue (busy), the body size, then not_a_pdf. So a request with a bad preset gets bad_preset even when the queue is full. See Self-hosting for the environment variables.

C API ​

hpdf_compress_file returns, and hpdf_compress_buffer sets *out_status to:

CodeMeaning
0Compressed. The output is written or returned.
2The input is signed. The output is an unchanged copy.
1Failed. hpdf_compress_buffer returns NULL. Read hpdf_last_error().

hpdf_last_error() returns an empty string after a success, or one of:

MessageFunctionWhat to do
cannot open input (missing, corrupt, or wrong password)hpdf_compress_fileCheck the path and the password.
cannot parse input (corrupt or wrong password)hpdf_compress_bufferCheck the bytes and the password.
engine pass failedbothThe engine could not process this file. Keep the original.
cannot open output for writinghpdf_compress_fileCheck that the output folder exists and is writable.
save failedbothWriting the result failed. Check disk space.
input larger than 2 GB is not supportedhpdf_compress_bufferUse hpdf_compress_file, or the worker binary.

The C API never makes the "never larger" comparison: compare sizes yourself and keep the original when it is smaller. See C API.

Worker exit codes ​

hpdf-worker, the engine program the native surfaces run, exits with:

Exit codeMeaning
0Success, including a signed input written unchanged.
1The engine pass failed.
2Wrong arguments.
3The input could not be opened (missing, corrupt or encrypted).
4The output could not be written.

When the SDK, CLI, crate or HTTP service runs the worker, a non-zero exit is not an error for you: Hyper falls back to a plain repack or to your original bytes. The exceptions: a worker that runs past the step limit gives timeout, and a failed pass on a file that needs a password you did not give gives decrypt_failed.

Troubleshooting ​

no hpdf-worker binary for <platform>. There is no native engine for this platform (for example Intel macOS, or Alpine Linux where npm skips the glibc packages). Use the WebAssembly package or the Docker image, or build the engine and set HYPER_DRV.

decrypt_failed with the right password. The file may have more than one password. Try the other one. Only the text before the first line break of a password is used.

timeout on large files. Each step has a 10 minute limit by default, and a size target runs the engine up to 11 times. Raise the limits, drop the target, or pick a preset closer to the size you need.

hpdf-worker not found at <path> or qpdf not found at <path>. HYPER_DRV, HYPER_QPDF or an explicit path in the Rust crate points to a file that does not exist. Fix the path or unset it.

busy from the HTTP API. Raise HYPER_CONCURRENCY if the machine has spare cores, raise HYPER_QUEUE to let more requests wait, or retry with backoff. See Running in production.

Output equals input with no error. Not an error: Hyper could not make the file smaller, or the input was signed.

Next steps ​

Dual-licensed under AGPL-3.0 and Commercial License.