-
Notifications
You must be signed in to change notification settings - Fork 57
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: supply system log to trusted plugins via FD #5391
Conversation
This pull request adds or modifies JavaScript ( |
Looks like tests are failing on Windows. There's a fair chance that this FD magic doesn't work on Windows, i'll have to investigate that. |
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.
I think this capability is nice, but I'm not a big fan of exposing the raw file descriptor to plugins. This feels leaky, and if we ever want to change the mechanism we use for system logs (like the structured logs idea that @JGAntunes shared) we'll have a hard time with existing plugins.
Could we instead add a systemLog
function to the properties we expose to build plugin hooks, which currently just wraps the logic for writing to the file description if available (and perhaps act as a no-op if not available), and further down the line we can swap the internals of that while maintaining the user-facing interface?
AFAICT, all properties we send to plugins are serialized because of the IPC bridge. If we send over a function, that would break during serialisation. If we had some sort of "bootstrap" code within the plugin, then we could set up said function in there. Thinking about it, we probably have something like that! I'll check that. |
We have things like |
Totally, yeah! Implemented in bbcad09 |
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.
Nice! 🚀
@@ -1,3 +1,4 @@ | |||
export const onBuild = function ({ featureFlags }) { | |||
export const onBuild = function ({ featureFlags, systemLog }) { |
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.
We should add this to the types.
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.
done in 6fa00d8
Tests failed on windows, because |
System logs are super useful for our internal observability. Giving system logs to (trusted) build plugins isn't straight-forward since plugins are run inside a child process. This PR is an attempt at bridging this, by sharing the system log file descriptor with the child process. This means build plugins will be able to write to system logs like this:
/dev/fd/4
is a bit of a magic name - but it works.There's still some tests failing, but I wanted to share the approach sooner than later, and get your feedback.