<p dir="auto">Possible Bug Report</p>
<p dir="auto">Using:<br>
deno 1.7.5 (release, x86_64-pc-windows-msvc)<br>
v8 9.0.123<br>
typescript 4.1.4</p>
<p dir="auto">Editor: VS Code 1.53.2, with intellisense plus Deno extension</p>
<p dir="auto">Standard Lib used:<br>
"<a href="https://deno.land/std@0.88.0/http/server.ts" rel="nofollow">https://deno.land/std@0.88.0/http/server.ts</a>"</p>
<p dir="auto">Class:<br>
import {serve} from "<a href="https://deno.land/std@0.88.0/http/server.ts" rel="nofollow">https://deno.land/std@0.88.0/http/server.ts</a>"</p>
<p dir="auto">Implementation:<br>
Async HTTP server through 'serve'<br>
Same problem probably with 'serveTLS' but I did not test that one yet.</p>
<p dir="auto">Problem Description<br>
All 'object' types {} inside ServerRequest and Server (and possibly others) are wrongly formatted.<br>
Hence JS doesn't recognize them and/or can't access them. For instance the HTTP headers variables such as 'host' or 'accept' cannot be reached (as an example). The error is consistent to ALL {} types.<br>
See conn: r: headers: w: w.writer: etc.</p>
<p dir="auto">Furthermore I think the ARRAY types [] have the same problem, but I didn't test yet. See w.buf</p>
<p dir="auto">REMARK: I do .js, could this have to do with .ts ? It kind of looks like the JSON format for {} and [] has been extended with a datatype.<br>
e.g.: headers: Headers {...}<br>
e.g.: w.buf: Uint8Array(4096) [...]</p>
<p dir="auto">CODE to reproduce the possible bug:</p>
<p dir="auto">In index.js file:</p>
<p dir="auto">import {serve} from "<a href="https://deno.land/std@0.88.0/http/server.ts" rel="nofollow">https://deno.land/std@0.88.0/http/server.ts</a>"<br>
import {dispatchRequest} from "./serving.js"</p>
<p dir="auto">// Setup Asyn server and make it listen/wait for incoming connections and serve them<br>
const server = serve({  "hostname": "127.0.0.1",  "port": 8080 });<br>
console.log("Server listening on port 8080");<br>
for await (const req of server) { req.respond(await dispatchRequest(req)); }</p>
<p dir="auto">In serving.js file:</p>
<p dir="auto">export async function dispatchRequest(req) {<br>
console.log(req);<br>
... sever respond code suppressed (not needed to demonstrate problem)<br>
}</p>
<p dir="auto">Test run<br>
Tested with URL : <a href="https://127.0.0.1:8080/test?abc=300" rel="nofollow">https://127.0.0.1:8080/test?abc=300</a><br>
Tested with Firefox and Chrome (both up to date)</p>
<p dir="auto">OUTPUT<br>
Bot test runs have identical OUTPUT in VS Code console as shown below:<br>
This is the output from the console.log() line in the serving.js file</p>
<p dir="auto">ServerRequest {<br>
conn: Conn {},<br>
r: BufReader {<br>
r: 367,<br>
w: 367,<br>
eof: false,<br>
buf: Uint8Array(4096) [<br>
71,  69,  84,  32,  47, 116, 101, 115, 116,  63, 97,  98,  99,  61,  51,<br>
48,  48,  32,  72,  84,  84,  80,  47,  49,  46, 49,  13,  10,  72, 111,<br>
115, 116,  58,  32,  49,  50,  55,  46,  48,  46, 48,  46,  49,  58,  56,<br>
48,  56,  48,  13,  10,  85, 115, 101, 114,  45, 65, 103, 101, 110, 116,<br>
58,  32,  77, 111, 122, 105, 108, 108,  97,  47, 53,  46,  48,  32,  40,<br>
87, 105, 110, 100, 111, 119, 115,  32,  78,  84, 32,  49,  48,  46,  48,<br>
59,  32,  87, 105, 110,  54,  52,  59,  32, 120,<br>
... 3996 more items<br>
],<br>
rd: Conn {}<br>
},<br>
method: "GET",<br>
url: "/test?abc=300",<br>
proto: "HTTP/1.1",<br>
protoMajor: 1,<br>
protoMinor: 1,<br>
headers: Headers { host: 127.0.0.1:8080, user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0, accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,<em>/</em>;q=0.8, accept-language: en-US,en;q=0.5, accept-encoding: gzip, deflate, dnt: 1, connection: keep-alive, upgrade-insecure-requests: 1, sec-gpc: 1 },<br>
w: BufWriter {<br>
usedBufferBytes: 0,<br>
err: null,<br>
writer: Conn {},<br>
buf: Uint8Array(4096) [<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
... 3996 more items<br>
]<br>
}<br>
}</p>
<p dir="auto">Problem Examples</p>
<p dir="auto">Example 1 (code added in serving.js):</p>
<p dir="auto">console.log(req.headers.toString());<br>
console.log(req.url.toString());<br>
var myJSON = JSON.stringify(req.headers);<br>
console.log(myJSON);</p>
<p dir="auto">OUTPUT:</p>
<p dir="auto">[object Headers] &lt;-- should be headers and not Headers, IMHO<br>
/test?abc=300 &lt;-- CORRECT, not an object {} type<br>
{} &lt;-- Should show content host: 127.0.0.1:8080 ... ect between the {}</p>
<p dir="auto">Example 2 (code added in serving.js):</p>
<p dir="auto">console.log(server.listener);<br>
console.log(server.listener.toString());<br>
var myJSON = JSON.stringify(server.listener);<br>
console.log(myJSON);</p>
<p dir="auto">OUTPUT:</p>
<p dir="auto">Listener {}<br>
[object Object]<br>
{} &lt;-- by coincidence correct because listener: is indeed an empty object {}.</p>
<p dir="auto">Possible/Probable cause</p>
<p dir="auto">I think this is a format problem, illustrated below for headers but actually it occurs for all OBJECT and possible all ARRAY types.</p>
<p dir="auto">The first general log above shows:</p>
<p dir="auto">headers: Headers { ... }</p>
<p dir="auto">The 'Headers ' with uppercase and space shouldn't be there IMO.</p>
<p dir="auto">Prove: I cut&amp;paste the log string from the first log above, removed the word and a space 'Headers '.<br>
The JSON.stringify() then works fine.</p>
<p dir="auto">This problem occurs on ALL objects {} definitions inside ServerRequest and Sever and possibly in plenty of others that I didn't check as the error is so consistent that it might be generated by some routine.<br>
Possibly the same for arrays  [] types (or all non simple types in general).</p>
<p dir="auto">If this is the case it could be the cause of many errors all over Deno, certainly in dependencies such as serveTLS.</p>
<p dir="auto">Possible Bug Report</p>
<p dir="auto">ATTENTION: I posted this ALSO on the main Deno thread because I think the underlying problem might not be at the std library level but deeper. Anyways, just in case it would be std related I post it here again.</p>
<p dir="auto">Using:<br>
deno 1.7.5 (release, x86_64-pc-windows-msvc)<br>
v8 9.0.123<br>
typescript 4.1.4</p>
<p dir="auto">Editor: VS Code 1.53.2, with intellisense plus Deno extension</p>
<p dir="auto">Standard Lib used:<br>
"<a href="https://deno.land/std@0.88.0/http/server.ts" rel="nofollow">https://deno.land/std@0.88.0/http/server.ts</a>"</p>
<p dir="auto">Class:<br>
import {serve} from "<a href="https://deno.land/std@0.88.0/http/server.ts" rel="nofollow">https://deno.land/std@0.88.0/http/server.ts</a>"</p>
<p dir="auto">Implementation:<br>
Async HTTP server through 'serve'<br>
Same problem probably with 'serveTLS' but I did not test that one yet.</p>
<p dir="auto">Problem Description<br>
All 'object' types {} inside ServerRequest and Server (and possibly others) are wrongly formatted.<br>
Hence JS doesn't recognize them and/or can't access them. For instance the HTTP headers variables such as 'host' or 'accept' cannot be reached (as an example). The error is consistent to ALL {} types.<br>
See conn: r: headers: w: w.writer: etc.</p>
<p dir="auto">Furthermore I think the ARRAY types [] have the same problem, but I didn't test yet. See w.buf</p>
<p dir="auto">REMARK: I do .js, could this have to do with .ts ? It kind of looks like the JSON format for {} and [] has been extended with a datatype.<br>
e.g.: headers: Headers {...}<br>
e.g.: w.buf: Uint8Array(4096) [...]</p>
<p dir="auto">CODE to reproduce the possible bug:</p>
<p dir="auto">In index.js file:</p>
<p dir="auto">import {serve} from "<a href="https://deno.land/std@0.88.0/http/server.ts" rel="nofollow">https://deno.land/std@0.88.0/http/server.ts</a>"<br>
import {dispatchRequest} from "./serving.js"</p>
<p dir="auto">// Setup Asyn server and make it listen/wait for incoming connections and serve them<br>
const server = serve({ "hostname": "127.0.0.1", "port": 8080 });<br>
console.log("Server listening on port 8080");<br>
for await (const req of server) { req.respond(await dispatchRequest(req)); }</p>
<p dir="auto">In serving.js file:</p>
<p dir="auto">export async function dispatchRequest(req) {<br>
console.log(req);<br>
... sever respond code suppressed (not needed to demonstrate problem)<br>
}</p>
<p dir="auto">Test run<br>
Tested with URL : <a href="https://127.0.0.1:8080/test?abc=300" rel="nofollow">https://127.0.0.1:8080/test?abc=300</a><br>
Tested with Firefox and Chrome (both up to date)</p>
<p dir="auto">OUTPUT<br>
Bot test runs have identical OUTPUT in VS Code console as shown below:<br>
This is the output from the console.log() line in the serving.js file</p>
<p dir="auto">ServerRequest {<br>
conn: Conn {},<br>
r: BufReader {<br>
r: 367,<br>
w: 367,<br>
eof: false,<br>
buf: Uint8Array(4096) [<br>
71, 69, 84, 32, 47, 116, 101, 115, 116, 63, 97, 98, 99, 61, 51,<br>
48, 48, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72, 111,<br>
115, 116, 58, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 56,<br>
48, 56, 48, 13, 10, 85, 115, 101, 114, 45, 65, 103, 101, 110, 116,<br>
58, 32, 77, 111, 122, 105, 108, 108, 97, 47, 53, 46, 48, 32, 40,<br>
87, 105, 110, 100, 111, 119, 115, 32, 78, 84, 32, 49, 48, 46, 48,<br>
59, 32, 87, 105, 110, 54, 52, 59, 32, 120,<br>
... 3996 more items<br>
],<br>
rd: Conn {}<br>
},<br>
method: "GET",<br>
url: "/test?abc=300",<br>
proto: "HTTP/1.1",<br>
protoMajor: 1,<br>
protoMinor: 1,<br>
headers: Headers { host: 127.0.0.1:8080, user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0, accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8, accept-language: en-US,en;q=0.5, accept-encoding: gzip, deflate, dnt: 1, connection: keep-alive, upgrade-insecure-requests: 1, sec-gpc: 1 },<br>
w: BufWriter {<br>
usedBufferBytes: 0,<br>
err: null,<br>
writer: Conn {},<br>
buf: Uint8Array(4096) [<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br>
... 3996 more items<br>
]<br>
}<br>
}</p>
<p dir="auto">Problem Examples</p>
<p dir="auto">Example 1 (code added in serving.js):</p>
<p dir="auto">console.log(req.headers.toString());<br>
console.log(req.url.toString());<br>
var myJSON = JSON.stringify(req.headers);<br>
console.log(myJSON);</p>
<p dir="auto">OUTPUT:</p>
<p dir="auto">[object Headers] &lt;-- should be headers and not Headers, IMHO<br>
/test?abc=300 &lt;-- CORRECT, not an object {} type<br>
{} &lt;-- Should show content host: 127.0.0.1:8080 ... ect between the {}</p>
<p dir="auto">Example 2 (code added in serving.js):</p>
<p dir="auto">console.log(server.listener);<br>
console.log(server.listener.toString());<br>
var myJSON = JSON.stringify(server.listener);<br>
console.log(myJSON);</p>
<p dir="auto">OUTPUT:</p>
<p dir="auto">Listener {}<br>
[object Object]<br>
{} &lt;-- by coincidence correct because listener: is indeed an empty object {}.</p>
<p dir="auto">Possible/Probable cause</p>
<p dir="auto">I think this is a format problem, illustrated below for headers but actually it occurs for all OBJECT and possible all ARRAY types.</p>
<p dir="auto">The first general log above shows:</p>
<p dir="auto">headers: Headers { ... }</p>
<p dir="auto">The 'Headers ' with uppercase and space shouldn't be there IMO.</p>
<p dir="auto">Prove: I cut&amp;paste the log string from the first log above, removed the word and a space 'Headers '.<br>
The JSON.stringify() then works fine.</p>
<p dir="auto">This problem occurs on ALL objects {} definitions inside ServerRequest and Sever and possibly in plenty of others that I didn't check as the error is so consistent that it might be generated by some routine.<br>
Possibly the same for arrays [] types (or all non simple types in general).</p>
<p dir="auto">If this is the case it could be the cause of many errors all over Deno, certainly in dependencies such as serveTLS.</p>