Skip to content

Commit 3aecbfc

Browse files
feat: log plugin initialisation error on single line (#5684)
1 parent 492b2e3 commit 3aecbfc

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

packages/build/src/plugins/system_log.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,20 @@ export const captureStandardError = (
1515
}
1616
}
1717

18-
let receivedChunks = false
18+
let buffer = ''
1919

2020
const listener = (chunk: Buffer) => {
21-
if (!receivedChunks) {
22-
receivedChunks = true
23-
24-
systemLog(`Plugin failed to initialize during the "${eventName}" phase`)
25-
}
26-
27-
systemLog(chunk.toString().trimEnd())
21+
buffer += chunk.toString()
2822
}
2923

3024
childProcess.stderr?.on('data', listener)
3125

3226
const cleanup = () => {
3327
childProcess.stderr?.removeListener('data', listener)
28+
29+
if (buffer.length !== 0) {
30+
systemLog(`Plugin failed to initialize during the "${eventName}" phase: ${buffer.trim()}`)
31+
}
3432
}
3533

3634
return cleanup

packages/build/tests/plugins/tests.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,8 @@ test('Plugin errors that occur during the loading phase are piped to system logs
360360

361361
if (platform !== 'win32') {
362362
const systemLog = await fs.readFile(systemLogFile.path, { encoding: 'utf8' })
363-
const lines = systemLog.split('\n')
364363

365-
t.is(lines[0].trim(), 'Plugin failed to initialize during the "load" phase')
366-
t.is(lines[1].trim(), 'An error message thrown by Node.js')
364+
t.is(systemLog.trim(), `Plugin failed to initialize during the "load" phase: An error message thrown by Node.js`)
367365
}
368366

369367
t.snapshot(normalizeOutput(output))

0 commit comments

Comments
 (0)