Add debugging to serveWeb to identify slow response generation

- Add debug logs for serveWeb calls and timing
- Measure content length and response creation time
- Help identify if createResponse is the bottleneck
- Debug Bad Gateway timeout issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
riz 2025-11-20 00:29:02 +00:00
parent d8e05e58cb
commit 177db0d3e5
1 changed files with 13 additions and 4 deletions

View File

@ -7,17 +7,26 @@ export const serveWeb = async (arg: {
cache_accept: string;
opt?: {
rewrite?: (arg: {
body: Bun.BodyInit;
body: Bun.BodyInputStream;
headers: Headers | any;
}) => Bun.BodyInit;
}) => Bun.BodyInputStream;
};
}) => {
const type = mime.getType(arg.pathname);
console.log(`[DEBUG] serveWeb called for: ${arg.pathname}, content length: ${arg.content.length}`);
const startTime = Date.now();
return createResponse(arg.content, {
const type = mime.getType(arg.pathname);
console.log(`[DEBUG] MIME type: ${type}`);
const response = createResponse(arg.content, {
cache_accept: arg.cache_accept,
high_compression: true,
headers: !type ? undefined : { "content-type": type },
rewrite: arg.opt?.rewrite,
});
const endTime = Date.now();
console.log(`[DEBUG] createResponse completed in ${endTime - startTime}ms`);
return response;
};