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 '
22
33import type { ChildProcess } from '../plugins/spawn.js'
44
@@ -14,9 +14,6 @@ export type StandardStreams = {
1414type LogsListener = ( logs : string [ ] , outputFlusher : OutputFlusher | undefined , chunk : Buffer ) => void
1515type LogsListeners = { stderrListener : LogsListener ; stdoutListener : LogsListener }
1616
17- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
18- const pSetTimeout = promisify ( setTimeout )
19-
2017// We try to use `stdio: inherit` because it keeps `stdout/stderr` as `TTY`,
2118// which solves many problems. However we can only do it in build.command.
2219// Plugins have several events, so need to be switch on and off instead.
@@ -67,7 +64,7 @@ export const unpipePluginOutput = async function (
6764 standardStreams : StandardStreams ,
6865) {
6966 // Let `childProcess` `stdout` and `stderr` flush before stopping redirecting
70- await pSetTimeout ( 0 )
67+ await setTimeout ( 0 )
7168
7269 if ( ! logsAreBuffered ( logs ) ) {
7370 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 '
22
33import { addErrorInfo } from '../error/info.js'
44import { addPluginLoadErrorStatus } from '../status/load_error.js'
@@ -7,8 +7,6 @@ import { measureDuration } from '../time/main.js'
77import { callChild } from './ipc.js'
88import { captureStandardError } from './system_log.js'
99
10- const pSetTimeout = promisify ( setTimeout )
11-
1210// Retrieve all plugins steps
1311// Can use either a module name or a file path to the plugin.
1412export const loadPlugins = async function ( {
@@ -112,7 +110,7 @@ const loadPlugin = async function (
112110 } catch ( error ) {
113111 if ( featureFlags . netlify_build_plugin_system_log ) {
114112 // Wait for stderr to be flushed.
115- await pSetTimeout ( 0 )
113+ await setTimeout ( 0 )
116114 }
117115
118116 addErrorInfo ( error , {
Original file line number Diff line number Diff line change 11import { createRequire } from 'module'
22import { platform } from 'os'
3+ import { setTimeout } from 'timers/promises'
34import { fileURLToPath , pathToFileURL } from 'url'
4- import { promisify } from 'util'
55
66import { trace } from '@opentelemetry/api'
77import { type ExecaChildProcess , execaNode } from 'execa'
@@ -30,7 +30,6 @@ import { captureStandardError } from './system_log.js'
3030export type ChildProcess = ExecaChildProcess < string >
3131
3232const CHILD_MAIN_FILE = fileURLToPath ( new URL ( 'child/main.js' , import . meta. url ) )
33- const pSetTimeout = promisify ( setTimeout )
3433const require = createRequire ( import . meta. url )
3534
3635// Start child processes used by all plugins
@@ -155,7 +154,7 @@ const startPlugin = async function ({
155154 } catch ( error ) {
156155 if ( featureFlags . netlify_build_plugin_system_log ) {
157156 // Wait for stderr to be flushed.
158- await pSetTimeout ( 0 )
157+ await setTimeout ( 0 )
159158 }
160159
161160 const spawnInfo = getSpawnInfo ( )
Original file line number Diff line number Diff line change 11import { env , kill } from 'process'
2- import { promisify } from 'util '
2+ import { setTimeout } from 'timers/promises '
33
44import { processExists } from 'process-exists'
55
6- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
7- const pSetTimeout = promisify ( setTimeout )
8-
96// 100ms
107const PROCESS_TIMEOUT = 1e2
118
@@ -15,6 +12,6 @@ export const onBuild = async function () {
1512 // Signals are async, so we need to wait for the child process to exit
1613 // The while loop is required due to `await`
1714 while ( await processExists ( env . TEST_PID ) ) {
18- await pSetTimeout ( PROCESS_TIMEOUT )
15+ await setTimeout ( PROCESS_TIMEOUT )
1916 }
2017}
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'
52
63export const onPreBuild = async function ( ) {
74 setTimeout ( function callback ( ) {
85 throw new Error ( 'test' )
96 } , 0 )
10- await pSetTimeout ( 0 )
7+ await setTimeoutPromise ( 0 )
118}
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'
52
63export const onPreBuild = async function ( ) {
74 unhandledPromise ( )
85 console . log ( 'onPreBuild' )
9- await pSetTimeout ( 0 )
6+ await setTimeout ( 0 )
107}
118
129const unhandledPromise = function ( ) {
Original file line number Diff line number Diff line change 11import { 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'
63
74// 1 second
85const WARNING_TIMEOUT = 1e3
96
107export const onPreBuild = async function ( ) {
118 emitWarning ( 'test' )
129 console . log ( 'onPreBuild' )
13- await pSetTimeout ( WARNING_TIMEOUT )
10+ await setTimeout ( WARNING_TIMEOUT )
1411}
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'
52
63// 100ms
74const LOG_TIMEOUT = 1e2
85
96export const onPreBuild = async function ( ) {
107 console . log ( 'one' )
11- await pSetTimeout ( LOG_TIMEOUT )
8+ await setTimeout ( LOG_TIMEOUT )
129 console . error ( 'two' )
13- await pSetTimeout ( LOG_TIMEOUT )
10+ await setTimeout ( LOG_TIMEOUT )
1411 console . log ( 'three' )
1512}
Original file line number Diff line number Diff line change 11import { 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'
63
74export const onPreBuild = async function ( {
85 utils : {
@@ -12,5 +9,5 @@ export const onPreBuild = async function ({
129 nextTick ( ( ) => {
1310 cancelBuild ( 'test' )
1411 } )
15- await pSetTimeout ( 0 )
12+ await setTimeout ( 0 )
1613}
Original file line number Diff line number Diff line change 11import { 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'
63
74export const onPreBuild = async function ( {
85 utils : {
@@ -12,5 +9,5 @@ export const onPreBuild = async function ({
129 nextTick ( ( ) => {
1310 failBuild ( 'test' )
1411 } )
15- await pSetTimeout ( 0 )
12+ await setTimeout ( 0 )
1613}
You can’t perform that action at this time.
0 commit comments