-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: emit system log when plugin has failed to load #5679
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
console.error("An error message thrown by Node.js") | ||
process.exit(1) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -347,3 +347,22 @@ test('Plugin events that do not emit to stderr/stdout are hidden from the logs', | |||
.runWithBuild() | ||||
t.snapshot(normalizeOutput(output)) | ||||
}) | ||||
|
||||
test('Plugin errors that occur during the loading phase are piped to system logs', async (t) => { | ||||
const systemLogFile = await tmp.file() | ||||
const output = await new Fixture('./fixtures/syntax_error') | ||||
.withFlags({ | ||||
debug: false, | ||||
featureFlags: { netlify_build_reduced_output: true, netlify_build_plugin_system_log: true }, | ||||
systemLogFile: systemLogFile.fd, | ||||
}) | ||||
.runWithBuild() | ||||
|
||||
if (platform !== 'win32') { | ||||
const systemLog = await fs.readFile(systemLogFile.path, { encoding: 'utf8' }) | ||||
|
||||
t.is(systemLog.trim(), 'An error message thrown by Node.js') | ||||
} | ||||
|
||||
t.snapshot(normalizeOutput(output)) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we replace the snapshot with a more precise assertion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The snapshot is just an accessory thing to ensure we're not throwing an unexpected error somewhere else. The main assertion is ensuring the stuff we pushed to stderr is piped to system logs: build/packages/build/tests/plugins/tests.js Line 364 in 59fe711
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's about asserting there's no error, maybe it's better to check something like build success? We're always complaining about the snapshot tests so much, so I think we shouldn't add them unnecessarily. |
||||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we unregister this after we're done initialising?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done in a0b4327.