Skip to content

Commit fb9be33

Browse files
authored
[Workers] Fix sample code in timers document (#24958)
1 parent 2f1a370 commit fb9be33

File tree

1 file changed

+5
-8
lines changed
  • src/content/docs/workers/runtime-apis/nodejs

1 file changed

+5
-8
lines changed

src/content/docs/workers/runtime-apis/nodejs/timers.mdx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ and [`setImmediate`](https://nodejs.org/api/timers.html#setimmediatecallback-arg
1818
import timers from "node:timers";
1919

2020
export default {
21-
async fetch() {
21+
async fetch(): Promise<Response> {
2222
console.log("first");
23-
const { promise1, resolve1 } = Promise.withResolvers();
24-
const { promise2, resolve2 } = Promise.withResolvers();
23+
const { promise: promise1, resolve: resolve1 } = Promise.withResolvers<void>();
24+
const { promise: promise2, resolve: resolve2 } = Promise.withResolvers<void>();
2525
timers.setTimeout(() => {
2626
console.log("last");
2727
resolve1();
@@ -35,10 +35,8 @@ export default {
3535
await Promise.all([promise1, promise2]);
3636

3737
return new Response("ok");
38-
39-
}
40-
}
41-
38+
}
39+
} satisfies ExportedHandler<Env>;
4240
```
4341
</TypeScriptExample>
4442

@@ -55,4 +53,3 @@ compatibility, you must call functions from the `node:timers` module.
5553
:::
5654

5755
The full `node:timers` API is documented in the [Node.js documentation for `node:timers`](https://nodejs.org/api/timers.html).
58-
```

0 commit comments

Comments
 (0)