- Home
- Skills
- APIs & Backend
- Repair Compression & Content Encoding Bugs
More screenshots
Works with the AI Agents you already use
Repair Compression & Content Encoding Bugs
Repair Compression & Content Encoding Bugs is a bounded ToolForge Labs workflow.
$1
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.
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.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Cannot verify production systems, external services, or facts that are not present in supplied evidence. With partial context it returns bounded diagnosis/review, explicit assumptions, and a deterministic validation plan rather than claiming successful execution.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago
Permissions
Use a clean branch or a controlled review workspace. Supply repository files, logs, traces, configuration, or evidence needed for the task. Review all patches/findings before merge or operational action; keep production credentials and destructive production actions out of the workflow.