File tree Expand file tree Collapse file tree 15 files changed +32
-79
lines changed
plugins/fixtures/interleave
zip-it-and-ship-it/src/runtimes/node/bundlers/zisi Expand file tree Collapse file tree 15 files changed +32
-79
lines changed Original file line number Diff line number Diff line change 1
- import { promisify } from 'util '
1
+ import { setTimeout } from 'timers/promises '
2
2
3
3
import type { ChildProcess } from '../plugins/spawn.js'
4
4
@@ -14,9 +14,6 @@ export type StandardStreams = {
14
14
type LogsListener = ( logs : string [ ] , outputFlusher : OutputFlusher | undefined , chunk : Buffer ) => void
15
15
type LogsListeners = { stderrListener : LogsListener ; stdoutListener : LogsListener }
16
16
17
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
18
- const pSetTimeout = promisify ( setTimeout )
19
-
20
17
// We try to use `stdio: inherit` because it keeps `stdout/stderr` as `TTY`,
21
18
// which solves many problems. However we can only do it in build.command.
22
19
// Plugins have several events, so need to be switch on and off instead.
@@ -67,7 +64,7 @@ export const unpipePluginOutput = async function (
67
64
standardStreams : StandardStreams ,
68
65
) {
69
66
// Let `childProcess` `stdout` and `stderr` flush before stopping redirecting
70
- await pSetTimeout ( 0 )
67
+ await setTimeout ( 0 )
71
68
72
69
if ( ! logsAreBuffered ( logs ) ) {
73
70
return unstreamOutput ( childProcess , standardStreams )
Original file line number Diff line number Diff line change 1
- import { promisify } from 'util '
1
+ import { setTimeout } from 'timers/promises '
2
2
3
3
import { addErrorInfo } from '../error/info.js'
4
4
import { addPluginLoadErrorStatus } from '../status/load_error.js'
@@ -7,8 +7,6 @@ import { measureDuration } from '../time/main.js'
7
7
import { callChild } from './ipc.js'
8
8
import { captureStandardError } from './system_log.js'
9
9
10
- const pSetTimeout = promisify ( setTimeout )
11
-
12
10
// Retrieve all plugins steps
13
11
// Can use either a module name or a file path to the plugin.
14
12
export const loadPlugins = async function ( {
@@ -112,7 +110,7 @@ const loadPlugin = async function (
112
110
} catch ( error ) {
113
111
if ( featureFlags . netlify_build_plugin_system_log ) {
114
112
// Wait for stderr to be flushed.
115
- await pSetTimeout ( 0 )
113
+ await setTimeout ( 0 )
116
114
}
117
115
118
116
addErrorInfo ( error , {
Original file line number Diff line number Diff line change 1
1
import { createRequire } from 'module'
2
2
import { platform } from 'os'
3
+ import { setTimeout } from 'timers/promises'
3
4
import { fileURLToPath , pathToFileURL } from 'url'
4
- import { promisify } from 'util'
5
5
6
6
import { trace } from '@opentelemetry/api'
7
7
import { type ExecaChildProcess , execaNode } from 'execa'
@@ -30,7 +30,6 @@ import { captureStandardError } from './system_log.js'
30
30
export type ChildProcess = ExecaChildProcess < string >
31
31
32
32
const CHILD_MAIN_FILE = fileURLToPath ( new URL ( 'child/main.js' , import . meta. url ) )
33
- const pSetTimeout = promisify ( setTimeout )
34
33
const require = createRequire ( import . meta. url )
35
34
36
35
// Start child processes used by all plugins
@@ -155,7 +154,7 @@ const startPlugin = async function ({
155
154
} catch ( error ) {
156
155
if ( featureFlags . netlify_build_plugin_system_log ) {
157
156
// Wait for stderr to be flushed.
158
- await pSetTimeout ( 0 )
157
+ await setTimeout ( 0 )
159
158
}
160
159
161
160
const spawnInfo = getSpawnInfo ( )
Original file line number Diff line number Diff line change 1
1
import { env , kill } from 'process'
2
- import { promisify } from 'util '
2
+ import { setTimeout } from 'timers/promises '
3
3
4
4
import { processExists } from 'process-exists'
5
5
6
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
7
- const pSetTimeout = promisify ( setTimeout )
8
-
9
6
// 100ms
10
7
const PROCESS_TIMEOUT = 1e2
11
8
@@ -15,6 +12,6 @@ export const onBuild = async function () {
15
12
// Signals are async, so we need to wait for the child process to exit
16
13
// The while loop is required due to `await`
17
14
while ( await processExists ( env . TEST_PID ) ) {
18
- await pSetTimeout ( PROCESS_TIMEOUT )
15
+ await setTimeout ( PROCESS_TIMEOUT )
19
16
}
20
17
}
Original file line number Diff line number Diff line change 1
- import { promisify } from 'util'
2
-
3
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
4
- const pSetTimeout = promisify ( setTimeout )
1
+ import { setTimeout as setTimeoutPromise } from 'timers/promises'
5
2
6
3
export const onPreBuild = async function ( ) {
7
4
setTimeout ( function callback ( ) {
8
5
throw new Error ( 'test' )
9
6
} , 0 )
10
- await pSetTimeout ( 0 )
7
+ await setTimeoutPromise ( 0 )
11
8
}
Original file line number Diff line number Diff line change 1
- import { promisify } from 'util'
2
-
3
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
4
- const pSetTimeout = promisify ( setTimeout )
1
+ import { setTimeout } from 'timers/promises'
5
2
6
3
export const onPreBuild = async function ( ) {
7
4
unhandledPromise ( )
8
5
console . log ( 'onPreBuild' )
9
- await pSetTimeout ( 0 )
6
+ await setTimeout ( 0 )
10
7
}
11
8
12
9
const unhandledPromise = function ( ) {
Original file line number Diff line number Diff line change 1
1
import { emitWarning } from 'process'
2
- import { promisify } from 'util'
3
-
4
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
5
- const pSetTimeout = promisify ( setTimeout )
2
+ import { setTimeout } from 'timers/promises'
6
3
7
4
// 1 second
8
5
const WARNING_TIMEOUT = 1e3
9
6
10
7
export const onPreBuild = async function ( ) {
11
8
emitWarning ( 'test' )
12
9
console . log ( 'onPreBuild' )
13
- await pSetTimeout ( WARNING_TIMEOUT )
10
+ await setTimeout ( WARNING_TIMEOUT )
14
11
}
Original file line number Diff line number Diff line change 1
- import { promisify } from 'util'
2
-
3
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
4
- const pSetTimeout = promisify ( setTimeout )
1
+ import { setTimeout } from 'timers/promises'
5
2
6
3
// 100ms
7
4
const LOG_TIMEOUT = 1e2
8
5
9
6
export const onPreBuild = async function ( ) {
10
7
console . log ( 'one' )
11
- await pSetTimeout ( LOG_TIMEOUT )
8
+ await setTimeout ( LOG_TIMEOUT )
12
9
console . error ( 'two' )
13
- await pSetTimeout ( LOG_TIMEOUT )
10
+ await setTimeout ( LOG_TIMEOUT )
14
11
console . log ( 'three' )
15
12
}
Original file line number Diff line number Diff line change 1
1
import { nextTick } from 'process'
2
- import { promisify } from 'util'
3
-
4
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
5
- const pSetTimeout = promisify ( setTimeout )
2
+ import { setTimeout } from 'timers/promises'
6
3
7
4
export const onPreBuild = async function ( {
8
5
utils : {
@@ -12,5 +9,5 @@ export const onPreBuild = async function ({
12
9
nextTick ( ( ) => {
13
10
cancelBuild ( 'test' )
14
11
} )
15
- await pSetTimeout ( 0 )
12
+ await setTimeout ( 0 )
16
13
}
Original file line number Diff line number Diff line change 1
1
import { nextTick } from 'process'
2
- import { promisify } from 'util'
3
-
4
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
5
- const pSetTimeout = promisify ( setTimeout )
2
+ import { setTimeout } from 'timers/promises'
6
3
7
4
export const onPreBuild = async function ( {
8
5
utils : {
@@ -12,5 +9,5 @@ export const onPreBuild = async function ({
12
9
nextTick ( ( ) => {
13
10
failBuild ( 'test' )
14
11
} )
15
- await pSetTimeout ( 0 )
12
+ await setTimeout ( 0 )
16
13
}
You can’t perform that action at this time.
0 commit comments