Skip to content

Commit

Permalink
fix: reading data from spawned process (#5877)
Browse files Browse the repository at this point in the history
  • Loading branch information
VitaliyR authored Oct 9, 2024
1 parent c482ddb commit 5860e72
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/build/src/plugins/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const getEventFromChild = async function (childProcess, callId) {
throw getChildExitError('Could not receive event from child process because it already exited.')
}

const messagePromise = pEvent(childProcess, 'message', { filter: ([actualCallId]) => actualCallId === callId })
const errorPromise = pEvent(childProcess, 'message', { filter: ([actualCallId]) => actualCallId === 'error' })
const messagePromise = pEvent(childProcess, 'message', { filter: (data) => data?.[0] === callId })
const errorPromise = pEvent(childProcess, 'message', { filter: (data) => data?.[0] === 'error' })
const exitPromise = pEvent(childProcess, 'exit', { multiArgs: true })
try {
return await Promise.race([getMessage(messagePromise), getError(errorPromise), getExit(exitPromise)])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: test
inputs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[[plugins]]
package = "./plugin.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import process from 'process';

export const onPreBuild = function () {
process.send({});
}
5 changes: 5 additions & 0 deletions packages/build/tests/plugins/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,8 @@ test('Plugins have a pre-populated Blobs context', async (t) => {

t.is(netlifyConfig.build.command, `echo ""Hello there""`)
})

test('Plugins can respond anything to parent process', async (t) => {
const build = await new Fixture('./fixtures/process_send_object').runBuildBinary()
t.true(build.exitCode === 0)
})

0 comments on commit 5860e72

Please sign in to comment.