Skip to content

Commit

Permalink
refactor: remove listener
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed May 28, 2024
1 parent 5598450 commit a0b4327
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/build/src/plugins/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ const loadPlugin = async function (
// this to system logs if we fail to load the plugin.
const bufferedStdErr = []

let bufferedStdListener

if (featureFlags.netlify_build_plugin_system_log && childProcess.stderr) {
childProcess.stderr.on('data', (data) => {
bufferedStdListener = (data) => {
bufferedStdErr.push(data.toString().trimEnd())
})
}

childProcess.stderr.on('data', bufferedStdListener)
}

try {
Expand Down Expand Up @@ -123,5 +127,9 @@ const loadPlugin = async function (
})
addPluginLoadErrorStatus({ error, packageName, version, debug })
throw error
} finally {
if (bufferedStdListener) {
childProcess.stderr.removeListener('data', bufferedStdListener)
}
}
}

0 comments on commit a0b4327

Please sign in to comment.