summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/testdata')
-rw-r--r--cli/tests/testdata/run/flash_shutdown/main.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/testdata/run/flash_shutdown/main.ts b/cli/tests/testdata/run/flash_shutdown/main.ts
new file mode 100644
index 000000000..7f6985e34
--- /dev/null
+++ b/cli/tests/testdata/run/flash_shutdown/main.ts
@@ -0,0 +1,23 @@
+// Copyright 2018-2022 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();
+ },
+});