mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(flash): panic if response if undefined (#15964)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
parent
2929ec9ffa
commit
35fe9ee530
2 changed files with 18 additions and 14 deletions
|
@ -1085,9 +1085,12 @@ Deno.test("upgradeHttpRaw tcp", async () => {
|
|||
const promise2 = deferred();
|
||||
const ac = new AbortController();
|
||||
const signal = ac.signal;
|
||||
const handler = async (req: Request) => {
|
||||
const [conn, _] = Deno.upgradeHttpRaw(req);
|
||||
let conn: Deno.Conn;
|
||||
let _head;
|
||||
const handler = (req: Request) => {
|
||||
[conn, _head] = Deno.upgradeHttpRaw(req);
|
||||
|
||||
(async () => {
|
||||
await conn.write(
|
||||
new TextEncoder().encode("HTTP/1.1 101 Switching Protocols\r\n\r\n"),
|
||||
);
|
||||
|
@ -1102,7 +1105,7 @@ Deno.test("upgradeHttpRaw tcp", async () => {
|
|||
assertEquals(secondPacketText, "bla bla bla\nbla bla\nbla\n");
|
||||
|
||||
promise2.resolve();
|
||||
conn.close();
|
||||
})();
|
||||
};
|
||||
const server = Deno.serve({
|
||||
// NOTE: `as any` is used to bypass type checking for the return value
|
||||
|
@ -1131,6 +1134,7 @@ Deno.test("upgradeHttpRaw tcp", async () => {
|
|||
);
|
||||
|
||||
await promise2;
|
||||
conn!.close();
|
||||
tcpConn.close();
|
||||
|
||||
ac.abort();
|
||||
|
|
|
@ -541,7 +541,7 @@
|
|||
let resp;
|
||||
try {
|
||||
resp = handler(req);
|
||||
if (resp instanceof Promise || typeof resp.then === "function") {
|
||||
if (resp instanceof Promise || typeof resp?.then === "function") {
|
||||
resp.then((resp) =>
|
||||
handleResponse(
|
||||
req,
|
||||
|
|
Loading…
Reference in a new issue