diff options
author | Rich Trott <rtrott@gmail.com> | 2021-06-06 04:57:30 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-06-11 08:24:56 +0300 |
commit | 0f65e414428fac6558673a7dbe937f8f3114cdbe (patch) | |
tree | aa51eb3848c631479d1a077d5dc373c3f5fea046 /lib | |
parent | f40725f2a1d536e1f2b59fcadb5c5085bbe74917 (diff) |
debugger: reduce scope of eslint disable comment
Current code masks setInterval and setTimeout with promisified versions.
This can be confusing to read and causes lint errors. Replace masking
with use of pSetInterval and pSetTimeout instead.
Move disabling of lint rule from entire file to the one remaining line
(after the above changes) that still needs it.
PR-URL: https://github.com/nodejs/node/pull/38946
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/inspector/_inspect.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/internal/inspector/_inspect.js b/lib/internal/inspector/_inspect.js index 427469b4a6f..6f8e389e421 100644 --- a/lib/internal/inspector/_inspect.js +++ b/lib/internal/inspector/_inspect.js @@ -20,9 +20,6 @@ * IN THE SOFTWARE. */ -// TODO(aduh95): remove restricted syntax errors -/* eslint-disable no-restricted-syntax */ - 'use strict'; const { @@ -53,8 +50,8 @@ const { EventEmitter } = require('events'); const net = require('net'); const util = require('util'); const { - setInterval, - setTimeout, + setInterval: pSetInterval, + setTimeout: pSetTimeout, } = require('timers/promises'); const { AbortController, @@ -85,13 +82,13 @@ async function portIsFree(host, port, timeout = 9999) { const ac = new AbortController(); const { signal } = ac; - setTimeout(timeout).then(() => ac.abort()); + pSetTimeout(timeout).then(() => ac.abort()); - const asyncIterator = setInterval(retryDelay); + const asyncIterator = pSetInterval(retryDelay); while (true) { await asyncIterator.next(); if (signal.aborted) { - throw new StartupError( + throw new StartupError( // eslint-disable-line no-restricted-syntax `Timeout (${timeout}) waiting for ${host}:${port} to be free`); } const error = await new Promise((resolve) => { @@ -251,7 +248,7 @@ class NodeInspector { return; } catch (error) { debuglog('connect failed', error); - await setTimeout(1000); + await pSetTimeout(1000); } } this.stdout.write(' failed to connect, please retry\n'); |