- Home
- Skills
- APIs & Backend
- Repair Compression & Content Encoding Bugs
More screenshots
Works with the AI tools you already use
Repair Compression & Content Encoding Bugs
Repair Compression & Content Encoding Bugs is a bounded ToolForge Labs workflow.
$8.99
Repair Compression & Content Encoding Bugs
Example session with this skill installed
Our Node.js proxy is intermittently truncating gzipped responses from an upstream service. Here is the middleware snippet. Fix the Content-Length and streaming logic.
- Read your context and instructions
- Compiled the repair compression
I have analyzed the middleware snippet. The issue stems from the proxy attempting to calculate Content-Length on the compressed stream before the flush is complete, leading to premature socket closure.
Streaming Compression Repair
const zlib = require('zlib');
const { pipeline } = require('stream');
// REPAIR: Remove manual Content-Length setting for dynamic streams.
// Use Transfer-Encoding: chunked to avoid truncation risks.
function proxyMiddleware(req, res, upstreamResponse) {
const acceptEncoding = req.headers['accept-encoding'] || '';
// Ensure we handle multiple encodings or lack thereof
if (acceptEncoding.includes('gzip')) {
res.setHeader('Content-Encoding', 'gzip');
res.setHeader('Transfer-Encoding', 'chunked');
res.removeHeader('Content-Length');
const gzip = zlib.createGzip({
flush: zlib.constants.Z_SYNC_FLUSH,
finishFlush: zlib.constants.Z_STREAM_END
});
pipeline(upstreamResponse, gzip, res, (err) => {
if (err) {
console.error('Pipeline failed:', err);
if (!res.headersSent) {
res.statusCode = 500;
res.end();
} else {
res.destroy(); // Terminate corrupted stream
}
}
});
} else {
upstreamResponse.pipe(res);
}
}
Invariants Applied
| Component | Responsibility | Strategy |
|---|---|---|
| Header Management | State Authority | Remove Content-Length when re-compressing to prevent mismatch. |
| Stream Lifecycle | Error Handling | Use pipeline for proper cleanup of all descriptors on failure. |
| Flush Policy | Wire Compatibility | Use Z_SYNC_FLUSH to ensure data reaches the client without buffering delays. |
Next steps
- Deploy to staging and verify the
Transfer-Encoding: chunkedheader is present in browser dev tools. - Run a load test with payloads larger than 64KB to ensure the buffer doesn't overflow.
- Check upstream logs to confirm the connection is not being reset by the proxy's timeout.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
Repair Compression & Content Encoding Bugs is a bounded ToolForge Labs workflow. Repair compression and content-encoding failures across gzip/deflate/brotli, charsets, byte-to-text boundaries, content length, streaming bodies, and decompression. Works from repositories or partial headers/payloads. Produces bounded repairs and deterministic fixtures while preserving wire compatibility, resource limits, and security safeguards. It works from a full repository or partial evidence such as snippets, logs, configuration, traces, tickets, and architecture notes. The skill preserves existing product and security policy, separates verified facts from assumptions, avoids invented execution claims, and produces concrete repair or review steps with focused deterministic validation or traceable evidence.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 21 days ago
- Passed all security checks, Safe to install