Anti-AIClone

Log date · Sun

How should javascript-obfuscator handle Pro quota errors?

Stop publication when obfuscation fails. Quota checks provide warning; isolate and verify the artifact before release.

What should a build do when Pro quota runs out?

Fail the build and prevent publication of any unverified artifact; a quota query is a warning, not a guarantee of success. In our local javascript-obfuscator 5.8.1 comparison, a valid sample produced 1,143 bytes and both versions printed DEMO-PLAN-154. Invalid input exited 1 and left no artifact in the clean release directory.

Questions and findings
QuestionFinding
What did 5.9.0 add?Pro quota query and machine-readable quota errors.
Local success path?109-byte input became 1,143 bytes; runtime output matched.
Local failure path?Exit 1; no release artifact.
Does a quota query guarantee success?No; a later request can still fail.

Released at 02:33 UTC on 2026-10-04, version 5.9.0 added getProQuota() for usage remaining on the API key’s plan. ApiError.code can identify dailyLimit or monthlyLimit. Its Node dist bundle also stopped being minified so uncaught errors have readable stack frames. [1]

Experiment: one gate for success and failure

We wrote a small pricing script and a second input with a syntax error, then ran the installed free 5.8.1 with Node 20.19.5. This older version of the same tool illustrates the pipeline issue; it is not a test of 5.9.0, the Pro service, real quotas or network failures. A fixed seed makes the run reproducible; sizes depend on the input and options.

The valid sample we wrote.
function quotePrice(quantity) {
  return 'DEMO-PLAN-' + (120 + quantity * 17);
}
console.log(quotePrice(2));

The script clears its output directory, promotes the staged file on success and deletes it on failure. The excerpt below is verbatim. Matching output covers this input and execution path only; different bytes establish neither protection strength nor complete functional correctness.

Excerpt from the experiment transcript.
== successful build ==
DEMO-PLAN-154
DEMO-PLAN-154
input bytes: 109
output bytes: 1143
files differ
== invalid input with clean staging ==
build: failed (exit 1)
release artifact: absent
diagnostic: Unexpected token (2:0)

Put quota checks inside the release gate

The 5.9.0 documentation defines remainingBytes as the smaller remaining daily or monthly allowance, or null for an unlimited plan. [3] A quota query can reveal a capacity problem early, but concurrent use, a network interruption or another error can occur between the query and the actual obfuscation. Abort publication on any failed obfuscation request, whether or not its code is dailyLimit or monthlyLimit. Use codes to classify alerts and investigate, not to allow other errors through.

Isolate each build’s output directory so a previous successful file cannot masquerade as the current result. Write a staged file, verify success and a nonempty output, run functional checks, then pass the approved artifact to the release step. Do not copy the original input as a fallback in a catch handler. Retain the build ID, tool version, configuration and error category; keep API tokens and source code out of logs.

The project README describes the free package as offline and Pro features as a token-based cloud API. It also says free output remains JavaScript and warns of 15–80% slowdown depending on options. [2] That is the project’s warning, not our performance measurement. Review service terms, retention and your data policy before sending source code.

Handing off the release artifact

Make the publication job accept only the file explicitly handed off by the verification step, and retain its build identifier and digest together. That lets the team trace which build supplied the file instead of relying on whatever happens to exist in a directory. A digest identifies bytes; it does not establish that the code was obfuscated correctly.

Include failure drills in pipeline maintenance: check retry limits, artifact retention and alert recipients, and repeat the exercise after configuration or tool upgrades. After a failure, confirm downstream jobs cannot bypass their dependency conditions and continue.

Recommendations by case

These are engineering recommendations, not effects measured by our experiment.

Release pipeline recommendations
CaseRecommendation
Quota is lowAlert early and plan capacity; still check the actual build result.
dailyLimit or monthlyLimitStop publication, record the category and resolve capacity.
Unknown error or timeoutStop as well; investigate and rerun the complete build.
An old artifact existsUse an isolated build directory and publish only the current verified file.
Core logic or keysDo not rely on client obfuscation for secrecy; keep privileged secrets server-side.

Choose retry limits and delays according to your service agreement. Unlimited retries can stall the pipeline and may consume more quota. After capacity returns, rebuild and repeat checks instead of enabling files left in a failed build directory.

Check your own project

Use the valid sample above and a second input with a syntax error to check the local success and failure paths with the following commands; replace the example paths with your own files. For your application, connect the checks to the real build configuration, use an isolated directory and a test token, and keep the token out of commands and logs.

Reproduce both local paths.
set -eu
output=$(mktemp -d)
javascript-obfuscator path/to/your-app/sample.js --output "$output/staged.js" --seed 123
node path/to/your-app/sample.js
node "$output/staged.js"
printf 'input bytes: '; wc -c < path/to/your-app/sample.js
printf 'output bytes: '; wc -c < "$output/staged.js"
if cmp -s path/to/your-app/sample.js "$output/staged.js"; then echo 'files identical'; else echo 'files differ'; fi
mv "$output/staged.js" "$output/release.js"
rm -f "$output/staged.js" "$output/release.js"
if javascript-obfuscator path/to/your-app/invalid.js --output "$output/staged.js" --seed 123 > "$output/failure.log" 2>&1; then
  mv "$output/staged.js" "$output/release.js"
  echo 'build: success'
else
  status=$?
  rm -f "$output/staged.js"
  printf 'build: failed (exit %s)\n' "$status"
fi
if test -e "$output/release.js"; then echo 'release artifact: present'; else echo 'release artifact: absent'; fi
printf 'diagnostic: '; grep -m 1 'Unexpected token' "$output/failure.log" | sed 's/^ *//'

In a test environment, exercise quota rejection, timeout and other failures separately. Confirm that the job fails and the publication step receives no artifact. Then run the success path and verify that the final release file came from the current build. Run critical functional, compatibility and performance regression tests on the obfuscated bundle and retain the version, options and diagnostic material for that build. Hashes or identifier searches can catch obvious mistakes, but alone cannot prove that protection is effective.

Your checklist

  • Check quota before the build, then check the actual obfuscation result.
  • Stop publication for quota, timeout and unknown errors.
  • Isolate each build directory and remove failed staged files.
  • Verify the current artifact and run functional and performance regression tests.
  • Review cloud source-handling policy and protect API tokens.

Primary sources

All sources and reproduction status ↗