deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

Top-level await promise never resolved

Open dong-lufei opened this issue 2 years ago • 3 comments

https://deno.land/[email protected]/examples/os_signals

According to your documentation, I run and report an error

import { signal } from "https://deno.land/[email protected]/signal/mod.ts";
// Windows 只支持 SIGINT 和 SIGBREAK
const sig = signal("SIGBREAK", "SIGINT");

// Add a timeout to prevent process exiting immediately.
setTimeout(() => {}, 5000);

for await (const _ of sig) {
  console.log("顶级等待承诺从未解决");
}

error: Top-level await promise never resolved for await (const _ of sig) { ^ at (file:///E:/test/deno/deno01/index.ts:667:18)

dong-lufei avatar Jan 28 '23 09:01 dong-lufei

What version of Deno are you using? What command are you using to run this code snippet? The documentation example works fine on my Mac (running Deno 1.30.0)

lino-levan avatar Jan 28 '23 15:01 lino-levan

I believe this is not a bug but the expected behavior in this case. I made an issue for the same thing a while back (note that the error message was different then): https://github.com/denoland/deno_std/issues/1941#issuecomment-1061293369

GJZwiers avatar Jan 29 '23 18:01 GJZwiers

# 13697 @ donglufei in E:\test\deno\deno01 [13:18:53]
$ deno run -A index.js
error: Top-level await promise never resolved
for await (const _ of sig) {
                 ^
    at <anonymous> (file:///E:/test/deno/deno01/index.js:146:18)

# 13697 @ donglufei in E:\test\deno\deno01 [13:19:02] C:1
$ deno -V
deno 1.30.0

# 13697 @ donglufei in E:\test\deno\deno01 [13:19:07]
$ deno run -A index.js
error: Top-level await promise never resolved
for await (const _ of sig) {
                 ^
    at <anonymous> (file:///E:/test/deno/deno01/index.js:146:18)

# 13697 @ donglufei in E:\test\deno\deno01 [13:19:14] C:1

dong-lufei avatar Jan 30 '23 05:01 dong-lufei

Closing this as std/signals was deprecated and removed from the Standard Library a while ago. Please take a look at the OS Signals documentation. If the code there doesn't work for your use case, please open a ticket in https://github.com/denoland/deno-docs.

iuioiua avatar Apr 16 '24 04:04 iuioiua