Repository navigation
Conversation
Member
Author
|
Superseded by #26, merged directly because the repository ruleset requires an approval from someone other than the PR author. The analysis stays in this PR's description. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #26
Changes
compression:text/lessas compressible (viacompressible2.0.16 andmime-db>= 1.38.0;compressiblealready treated it as compressible through itstext/*fallback); fixes theres.writeHeadpatch missing its return value (viaon-headers1.0.2); perf: prevents an unnecessary buffer copy when aBufferchunk is writtenacceptswithnegotiator~0.6.4, which adds an encoding preference option (Replace accepts with negotiator expressjs/compression#197); also removes the override that switched fromdeflatetogzipwhenever the client accepted gzip, and passesgzipas the preferred encoding instead, which only breaks ties between equal q-values;bytes3.1.2 (adds petabytepbsupport, fixesthousandsSeparatorformatting the fractional part, fixes the return value for unparsable strings);compressible~2.0.18 (marksfont/ttfas compressible, drops thecompressible: falseflag frommultipart/mixed, which stays not compressible,mime-db>= 1.43.0);safe-buffer5.2.1res.headersSentwhen available instead ofres._header(Use headersSent instead of _header expressjs/compression#129); callsres.writeHead()instead of the privateres._implicitHeader()(Bugfix/use write head instead of implicit header expressjs/compression#170); adds Brotli support on Node.js versions that have it, with a newbrotlioption and a default quality of 4, and prefersbrovergzipwhen the client accepts both with equal quality (feat: support for brotli expressjs/compression#194); adds theenforceEncodingoption for requests without anAccept-Encodingheader, defaultidentity(feat: add default option expressjs/compression#191); refactorschunkLength(),toBuffer()and the encoding negotiation logic (Refactor chunkLength function for improved readability and consistency expressjs/compression#203, Refactor toBuffer function to simplify buffer check logic expressjs/compression#201, refactor: simplify encoding negotiation logic expressjs/compression#213)on-headers~1.1.0, which fixes CVE-2025-7339 (GHSA-76c9-3jph-rj3q, low, response headers could be modified unintentionally when an array is passed tores.writeHead())destroy1.2.0; matches theCache-Control: no-transformdirective case-insensitively (fix: match Cache-Control no-transform directive case-insensitively expressjs/compression#286)HISTORY.mdin the npm package (doc(package): remove history.md and add readme.md to published files expressjs/compression#270).Dependencies of
compressionthat change (each is used only bycompression; the other copies in the tree stay as they are):negotiator0.6.1 → 0.6.4 (new nested copy;acceptskeeps 0.6.1): 0.6.2 fixes the sorting of charsets, encodings and languages with extra parameters; 0.6.3 reverts the lazy-loading of modules from the main entry point; 0.6.4 adds the preferred encodings argument (Added an option preferred encodings array jshttp/negotiator#59) and replaces the deprecatedString.prototype.substr()on-headers1.0.1 → 1.1.0: 1.0.2 fixes theres.writeHeadpatch missing its return value; 1.1.0 fixes CVE-2025-7339 (see 1.8.1)compressible2.0.14 → 2.0.18, with a new nestedmime-db1.54.0 (the top-levelmime-db1.35.0 stays formime-types): 2.0.15 to 2.0.17 raise themime-dbrange; 2.0.16 markstext/lessas compressible, whichcompressiblealready did through itstext/*fallback; 2.0.18 marksfont/ttfas compressible and drops thecompressible: falseflag frommultipart/mixed, which stays not compressible;mime-db1.35.0 → 1.54.0 adds media types and their compressible flagsbytes3.0.0 → 3.1.2 (new nested copy;body-parserandraw-bodykeep 3.0.0): 3.1.0 adds petabyte support; 3.1.1 fixesthousandsSeparatorformatting the fractional part; 3.1.2 fixes the return value for unparsable stringssafe-buffer5.1.2 → 5.2.1 (nested copy): 5.2.0 makes theSafeBufferprototype inherit fromBuffer; 5.2.1 has no functional changesdestroy1.2.0 (new dependency, nested;sendkeeps 1.0.4): 1.1.0 adds zlib stream support and a Node.js leak workaround; 1.1.1 works around a zlib close bug in Node.js < 4.5.5; 1.2.0 adds thesuppressargumentacceptsis no longer used bycompression; it stays in the tree forexpress,express-graphqlandserve-index.compressionis a transitive production dependency ofwebpack-dev-server3.1.5 in thetodosubproject (compression@^1.5.2).webpack-dev-server3.1.5 loads the module at startup, but mounts the middleware, ascompress()without options, only when itscompressoption is truthy. The todoserver.jscreatesWebpackDevServerwith onlycontentBase,publicPathandstats, so the middleware is not mounted in this app, and the upgrade does not change how the app handles requests. Ifcompresswere enabled, the default options would behave differently in these ways:brandgzipwith equal quality, as current browsers do, would receive Brotli-compressed responses (Content-Encoding: br, quality 4) instead of gzip on Node.js versions with Brotli support.deflateto gzip whenever the client accepted gzip no longer exists, and the preferred encodings (br,gzip) only break ties between equal q-values. A client that givesdeflatea higher q-value thangzipwould get deflate instead of gzip, and a client that listsidentitybeforegzipat equal q-values would get gzip instead of an uncompressed response. Both are edge cases.Cache-Controlheader withno-transformin any letter case would disable compression.mime-db1.54.0 instead of 1.35.0; for example,font/ttfwould now be compressed.text/lesswas already compressed through thetext/*fallback, andmultipart/mixedstays uncompressed.The default
thresholdstays 1 KiB, the defaultfilterlogic is unchanged,Vary: Accept-Encodingis still set, and requests withoutAccept-Encodingstill get an uncompressed response, becauseenforceEncodingdefaults toidentity.The strictest
engines.nodeamong the new package versions is>= 0.8, and thetodosubproject declares noengines. The legacy root.travis.yml(Node.js 6, 8 and 10, runningnpm install,npm run update-schemaandnpm run buildin./todo) is inactive, as no Travis check reports on this PR; Node.js 6 would also satisfy these ranges.Risk
Medium.
compressionmoves across a minor version with changed encoding negotiation: the override that switched from deflate to gzip is gone since 1.7.5, Brotli is preferred over gzip since 1.8.0, andnegotiatormoves from 0.6.1 to 0.6.4 with the new preferred encodings argument.on-headers1.1.0 changes howres.writeHead()applies array headers,compressibleandmime-dbchange the set of compressible types, and the newdestroydependency handles the stream on response close. None of this affects the todo app, becausewebpack-dev-serverdoes not mount the middleware without thecompressoption.Breaking Changes
None
Code Changes Required
None — the upgrade is a drop-in replacement.
compressionis a transitive dependency in thetodosubproject. Intodo/package-lock.jsonandtodo/yarn.lock, only the entries ofcompressionand its own dependencies change:compression,compressible,on-headersand the nestedsafe-bufferare updated, and nestedbytes,destroy,negotiatorandmime-dbentries are added. Inyarn.lock, the newsafe-buffer@5.2.1range resolves to the existingsafe-buffer5.2.1 entry, and thesafe-buffer@5.1.2andmime-db@>= 1.34.0 < 2ranges are removed from the headers of the existingsafe-buffer5.1.2 andmime-db1.35.0 entries, which other packages still use. The lock-file changes are identical to the bot PR's, because npm 10 rewritesyarn.lockand unrelatedpackage-lock.jsonfields in this subproject; npm resolves the same entries.Summary by CodeRabbit