Skip to content
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

Merged
merged 3 commits into from
May 28, 2024

Conversation

eduardoboucas
Copy link
Member

Summary

Right now we don't have any visibility over errors that occur when loading a plugin. This PR tries to address that by emitting system logs for any failures that happen during the plugin loading stage.

@eduardoboucas eduardoboucas requested review from a team as code owners May 28, 2024 13:45
Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@eduardoboucas eduardoboucas requested review from Skn0tt and JGAntunes May 28, 2024 13:49
Copy link
Contributor

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach looks good and the test gives confidence. Leaving some questions.

t.is(systemLog.trim(), 'An error message thrown by Node.js')
}

t.snapshot(normalizeOutput(output))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace the snapshot with a more precise assertion?

Copy link
Member Author

Choose a reason for hiding this comment

The 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:

t.is(systemLog.trim(), 'An error message thrown by Node.js')

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

const bufferedStdErr = []

if (featureFlags.netlify_build_plugin_system_log && childProcess.stderr) {
childProcess.stderr.on('data', (data) => {
Copy link
Contributor

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?

Copy link
Member Author

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.

@eduardoboucas eduardoboucas requested a review from Skn0tt May 28, 2024 13:59
@eduardoboucas eduardoboucas enabled auto-merge (squash) May 28, 2024 14:01
@eduardoboucas eduardoboucas merged commit 0efec6d into main May 28, 2024
37 checks passed
@eduardoboucas eduardoboucas deleted the feat/plugin-load-syslog branch May 28, 2024 14:18
This was referenced Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants