ARTIFACTORY: How to Fix Large npm Metadata JSON and Whitespace Expansion in Artifactory

Products
Frog_Artifactory
Content Type
Use_Case
AuthorFullName__c
Pratham D Hegde
articleNumber
000007139
FirstPublishedDate
2026-08-26T14:32:07Z
lastModifiedDate
2026-08-26

ARTIFACTORY: How to Fix Large npm Metadata JSON and Whitespace Expansion in Artifactory

Overview
In Artifactory 7.146.x, npm package metadata responses may become significantly larger than expected due to excessive whitespace being added to the JSON output. Although the JSON remains valid, the increased response size can result in slow downloads, client timeouts, or increased memory usage.
A common indicator is that the metadata returned by Artifactory is substantially larger than the same metadata from registry.npmjs.org, while removing whitespace from the Artifactory response reduces its size to approximately the same as the upstream response.Usually seen on Self-Hosted when startup hook install fails


Cause
Artifactory installs a runtime mitigation during startup to prevent excessive whitespace from being generated in npm metadata responses. If the JVM does not allow the required self-attach operation, the mitigation cannot be installed, causing the whitespace expansion issue to occur.Triggered under concurrent npm metadata requests; not limited to specific packages (e.g. lodash, storybook are common examples).


How to Confirm
Review the Artifactory startup logs after a restart.If the runtime mitigation was installed successfully, the logs should contain:
Registered the DefaultPrettyPrinter clone-on-set hook
If the mitigation could not be installed, the logs will contain an error similar to:
Failed installing the DefaultPrettyPrinter fix hook
Note:

These log messages are only generated during Artifactory startup.


Resolution:
Configure the JVM to allow self-attachment by adding the following option to system.yaml:
shared:
    extraJavaOpts: "-Djdk.attach.allowAttachSelf=true"
Restart Artifactory after applying the change.


Verification
A small size difference vs npmjs after fix is expected (Artifactory pretty-prints; upstream is compact).
After restarting Artifactory:
  • Verify that the startup logs contain:
Registered the DefaultPrettyPrinter clone-on-set hook
  • Ensure the following message is not present:
Failed installing the DefaultPrettyPrinter fix hook