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:
parent
d8e05e58cb
commit
177db0d3e5
|
|
@ -7,17 +7,26 @@ export const serveWeb = async (arg: {
|
||||||
cache_accept: string;
|
cache_accept: string;
|
||||||
opt?: {
|
opt?: {
|
||||||
rewrite?: (arg: {
|
rewrite?: (arg: {
|
||||||
body: Bun.BodyInit;
|
body: Bun.BodyInputStream;
|
||||||
headers: Headers | any;
|
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,
|
cache_accept: arg.cache_accept,
|
||||||
high_compression: true,
|
high_compression: true,
|
||||||
headers: !type ? undefined : { "content-type": type },
|
headers: !type ? undefined : { "content-type": type },
|
||||||
rewrite: arg.opt?.rewrite,
|
rewrite: arg.opt?.rewrite,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const endTime = Date.now();
|
||||||
|
console.log(`[DEBUG] createResponse completed in ${endTime - startTime}ms`);
|
||||||
|
|
||||||
|
return response;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue