0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 12:10:08 +01:00
Commit Graph

22 Commits

Author SHA1 Message Date
Gürgün Dayıoğlu
7788999ac1
lib: remove unnecessary optional chaining
PR-URL: https://github.com/nodejs/node/pull/55728
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2024-11-07 15:59:12 +00:00
Yagiz Nizipli
f38cefa04b
lib: use Promise.withResolvers() in timers
PR-URL: https://github.com/nodejs/node/pull/55720
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2024-11-06 17:17:31 +00:00
Paolo Insogna
294ae14b98
timers: document ref option for scheduler.wait
PR-URL: https://github.com/nodejs/node/pull/54605
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
2024-09-02 06:57:02 +00:00
Paolo Insogna
6d654ddd00
timers: fix validation
PR-URL: https://github.com/nodejs/node/pull/54404
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
2024-08-25 07:30:10 +00:00
Chemi Atlow
78f6952751
fs: use kResistStopPropagation
PR-URL: https://github.com/nodejs/node/pull/48521
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2023-06-24 15:52:38 +00:00
Antoine du Hamel
cbcefdf253
lib: enforce use of trailing commas in more files
Some part of the codebase already use trailing commas, this commit is
adding a lint rule to ensure it stays this way.
This commit also adds the rule for a few files that were missing only
one or two trailing commas.

PR-URL: https://github.com/nodejs/node/pull/46655
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2023-02-16 18:47:24 +01:00
James M Snell
06b28fbadc
timers: cleanup no-longer relevant TODOs in timers/promises
PR-URL: https://github.com/nodejs/node/pull/46499
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-02-05 10:12:16 +00:00
LiviaMedeiros
cacd72eb63
timers: use kEmptyObject
PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-06-11 12:18:15 +02:00
Antoine du Hamel
2ff61fd1cd
tools: add timers functions to the list of restricted globals
PR-URL: https://github.com/nodejs/node/pull/42013
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
2022-02-18 11:37:36 +00:00
James M Snell
8bce46aff1
timers: add experimental scheduler api
Adds experimental implementations of the yield and wait APIs being
explored at https://github.com/WICG/scheduling-apis.

When I asked the WHATWG folks about the possibility of standardizing the
[awaitable versions of setTimeout/setImmediate](https://github.com/whatwg/html/issues/7340)
that we have implemented in `timers/promises`, they pointed at the work
in progress scheduling APIs draft as they direction they'll be going.
While there is definitely a few thing in that draft that have
questionable utility to Node.js, the yield and wait APIs map cleanly to
the setImmediate and setTimeout we already have.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/40909
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-12-05 07:36:50 -08:00
James M Snell
a2982798e3
timers: propagate signal.reason in awaitable timers
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/41008
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2021-12-02 12:13:00 -08:00
Antoine du Hamel
2eeb4e1d94
lib: make primordials Promise methods safe
`catch` and `finally` methods on %Promise.prototype% looks up the `then`
property of the instance, making it at risk of prototype pollution.

PR-URL: https://github.com/nodejs/node/pull/38650
Refs: https://tc39.es/ecma262/#sec-promise.prototype.catch
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-05-19 09:21:37 -07:00
Giora Guttsait
d9b56fe295 timers: remove redundant unref calls
PR-URL: https://github.com/nodejs/node/pull/38320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-24 15:05:22 -07:00
Matteo Collina
a0261d231c
Revert "timers: refactor to use optional chaining"
This reverts commit d8f535b025.

PR-URL: https://github.com/nodejs/node/pull/38245
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-19 23:34:15 +01:00
linkgoron
fefc639016 timers: introduce setInterval async iterator
Added setInterval async generator to timers\promises.
Utilises async generators to provide an iterator compatible with
`for await`.

Co-Authored-By: Fabian Cook <hello@fabiancook.dev>

fix message

PR-URL: https://github.com/nodejs/node/pull/37153
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-03 19:28:09 +02:00
ZiJian Liu
d8f535b025
timers: refactor to use optional chaining
PR-URL: https://github.com/nodejs/node/pull/36767
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-09 15:18:34 -08:00
ZiJian Liu
4905501741 quic,timers: refactor to use validateAbortSignal
PR-URL: https://github.com/nodejs/node/pull/36604
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2020-12-27 06:37:30 -08:00
Benjamin Gruenbaum
1ed72f67f5 timers: reject with AbortError on cancellation
PR-URL: https://github.com/nodejs/node/pull/36317
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2020-12-01 18:51:05 +00:00
Antoine du Hamel
bd120207fb timers: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36132
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-11-18 04:21:24 -08:00
James M Snell
aa1eb1fd59 timers: cleanup abort listener on awaitable timers
Co-authored-by: Benjamin Gruenbaum <benjamingr@gmail.com>
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36006
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-11-09 08:23:10 +00:00
Anna Henningsen
5d179cb2ec timers: use AbortController with correct name/message
On the web, `AbortError` is the error name, not the error
message. Change the code to match that.

PR-URL: https://github.com/nodejs/node/pull/34763
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-08-15 14:48:13 -07:00
James M Snell
a8904e8eee
timers: introduce timers/promises
Move the promisified timers implementations into a new sub-module
to avoid the need to promisify. The promisified versions now return
the timers/promises versions.

Also adds `ref` option to the promisified versions

```js
const {
  setTimeout,
  setImmediate
} = require('timers/promises');

setTimeout(10, null, { ref: false })
  .then(console.log);

setImmediate(null, { ref: false })
  .then(console.log);

```

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/33950
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2020-06-22 14:29:49 -07:00