fresh icon indicating copy to clipboard operation
fresh copied to clipboard

TypeError: Invalid URL: 'google.com'

Open liigo opened this issue 2 years ago • 3 comments

my fresh site got many TypeErrors recently:

TypeError: Invalid URL: 'google.com'
    at getSerialization (ext:deno_url/00_url.js:89:11)
    at new URL (ext:deno_url/00_url.js:380:27)
    at handler (https://deno.land/x/[email protected]/src/server/context.ts:185:19)
    at https://deno.land/x/[email protected]/src/server/boot.ts:81:9
    at ext:deno_http/00_serve.js:448:24
    at ext:deno_http/00_serve.js:673:29
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async bootServer (https://deno.land/x/[email protected]/src/server/boot.ts:78:5)
    at async startServer (https://deno.land/x/[email protected]/src/server/boot.ts:39:5)
    at async start (https://deno.land/x/[email protected]/src/server/mod.ts:115:3)

the site has no public domain, only private IP, I have no idea why google can access it.

liigo avatar Dec 15 '23 10:12 liigo

That error is not the referrer but rather the actual URL that is sent to the Fresh instance. The part in question here that threw the error, runs just after receiving the Request object from deno through Deno.serve. The first thing we do in Fresh is construct a proper URL object out of it. That's were this fails because google.com is not a valid URL.

Do you have an idea who could be sending those invalid requests to your Fresh instance?

marvinhagemeister avatar Dec 15 '23 11:12 marvinhagemeister

I get the same error from time to time in the production logs. This has been happening for a long time.

It was 'google.com' for a long time but now it's 'www.sneakersnstuff.com'

NanoEdit avatar Dec 15 '23 21:12 NanoEdit

@marvinhagemeister

Do you have an idea who could be sending those invalid requests to your Fresh instance?

I found that MS Edge browser may also send similar invalid requests. (...oh, maybe not invalid, i don't know.)

To reproduce the problem, just set 127.0.0.1:8000 as Windows HTTP proxy, and visit any url in Edge.

TypeError: Invalid URL: 'nav-edge.smartscreen.microsoft.com'
    at getSerialization (ext:deno_url/00_url.js:91:11)
    at new URL (ext:deno_url/00_url.js:382:27)
    at handler (https://deno.land/x/[email protected]/src/server/context.ts:185:19)
    at https://deno.land/x/[email protected]/src/server/boot.ts:81:9
    at ext:deno_http/00_serve.js:459:24
    at ext:deno_http/00_serve.js:673:33
    at eventLoopTick (ext:core/01_core.js:178:11)
    at async bootServer (https://deno.land/x/[email protected]/src/server/boot.ts:78:5)
    at async startServer (https://deno.land/x/[email protected]/src/server/boot.ts:39:5)
    at async dev (https://deno.land/x/[email protected]/src/dev/dev_command.ts:58:5)
TypeError: Invalid URL: 'browser.events.data.msn.cn'
    at getSerialization (ext:deno_url/00_url.js:91:11)
    at new URL (ext:deno_url/00_url.js:382:27)
    at handler (https://deno.land/x/[email protected]/src/server/context.ts:185:19)
    at https://deno.land/x/[email protected]/src/server/boot.ts:81:9
    at ext:deno_http/00_serve.js:459:24
    at ext:deno_http/00_serve.js:673:33
    at eventLoopTick (ext:core/01_core.js:178:11)
    at async bootServer (https://deno.land/x/[email protected]/src/server/boot.ts:78:5)
    at async startServer (https://deno.land/x/[email protected]/src/server/boot.ts:39:5)
    at async dev (https://deno.land/x/[email protected]/src/dev/dev_command.ts:58:5)

Edit: more details, note the CONNECT method

Deno.serve((req) => {
    console.log("====>", req);
    return new Response("just test");
});
Listening on http://localhost:8000/
====> Request {
  bodyUsed: false,
  headers: Headers {
    host: "mobile.events.data.microsoft.com:443",
    "proxy-connection": "keep-alive",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.85.0 Chrome/"... 44 more characters
  },
  method: "CONNECT",
  redirect: undefined,
  url: "mobile.events.data.microsoft.com:443"
}
====> Request {   
  bodyUsed: false,
  headers: Headers {
    accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/si"... 24 more characters,
    "accept-encoding": "gzip, deflate, br",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
    "cache-control": "max-age=0",
    connection: "keep-alive",
    dnt: "1",
    host: "localhost:8000",
    "sec-ch-ua": '"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": '"Windows"',
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "none",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Sa"... 25 more characters
  },
  method: "GET",
  redirect: undefined,
  url: "http://localhost:8000/"
}
====> Request {
  bodyUsed: false,
  headers: Headers {
    accept: "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
    "accept-encoding": "gzip, deflate, br",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
    connection: "keep-alive",
    dnt: "1",
    host: "localhost:8000",
    referer: "http://localhost:8000/",
    "sec-ch-ua": '"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": '"Windows"',
    "sec-fetch-dest": "image",
    "sec-fetch-mode": "no-cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Sa"... 25 more characters
  },
  method: "GET",
  redirect: undefined,
  url: "http://localhost:8000/favicon.ico"
}
====> Request {
  bodyUsed: false,
  headers: Headers {
    host: "mobile.events.data.microsoft.com:443",
    "proxy-connection": "keep-alive",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.85.0 Chrome/"... 44 more characters
  },
  method: "CONNECT",
  redirect: undefined,
  url: "mobile.events.data.microsoft.com:443"
}

liigo avatar Dec 16 '23 03:12 liigo