1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00
denoland-deno/cli/tests/testdata/run/flash_shutdown/main.ts
David Sherret 10e4b2e140
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00

23 lines
653 B
TypeScript

// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Deno.serve caused segfault with this example after #16383
// refs:
// - https://github.com/denoland/deno/pull/16383
// - https://github.com/denoland/deno_std/issues/2882
// - revert https://github.com/denoland/deno/pull/16610
const ctl = new AbortController();
Deno.serve(() =>
new Promise((resolve) => {
resolve(new Response(new TextEncoder().encode("ok")));
ctl.abort();
}), {
signal: ctl.signal,
async onListen({ port }) {
const a = await fetch(`http://localhost:${port}`, {
method: "POST",
body: "",
});
await a.text();
},
});