Skip to content

Commit

Permalink
fix favicon 404 ignore error
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 8, 2020
1 parent 9ca5c38 commit 899dd10
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions snowpack/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ const sendFile = (
};

const sendError = (req: http.IncomingMessage, res: http.ServerResponse, status: number) => {
logger.error(`[${status}] ${req.url}`);
if (!(req.url === '/favicon.ico' && status === 404)) {
logger.error(`[${status}] ${req.url}`);
}
const contentType = mime.contentType(path.extname(req.url!) || '.html');
const headers: Record<string, string> = {
'Access-Control-Allow-Origin': '*',
Expand Down Expand Up @@ -482,13 +484,11 @@ export async function startServer(commandOptions: CommandOptions) {
const fileLoc = await getFileFromUrl(reqPath);

if (!fileLoc) {
const attemptedFilesMessage = attemptedFileLoads.map((loc) => ' ✘ ' + loc).join('\n');
const errorMessage = `[404] ${reqUrl}\n${attemptedFilesMessage}`;
// Log any favicon 404s at the "debug" level, only. Browsers automatically request a favicon.ico file
// Don't log favicon "Not Found" errors. Browsers automatically request a favicon.ico file
// from the server, which creates annoying errors for new apps / first experiences.
if (reqPath === '/favicon.ico') {
logger.debug(errorMessage);
} else {
if (reqPath !== '/favicon.ico') {
const attemptedFilesMessage = attemptedFileLoads.map((loc) => ' ✘ ' + loc).join('\n');
const errorMessage = `[404] ${reqUrl}\n${attemptedFilesMessage}`;
logger.error(errorMessage);
}
return sendError(req, res, 404);
Expand Down

1 comment on commit 899dd10

@vercel
Copy link

@vercel vercel bot commented on 899dd10 Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.