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

Fix lack of newlines in subprocess logging #654

Merged
merged 3 commits into from
May 22, 2024
Merged

Conversation

ivomurrell
Copy link
Contributor

Description

This partially reverts d1374d1, which I think was a mistake as we already remove the EOL character normally added by winston, and we skip appending a newline character to messages if it has a process attribute. So it meant that the only newlines that would be preserved were ones that happened to not be at the end (or start) of a stream flush.

Running the Mocha task in next-static before this change:
Screenshot 2024-05-20 at 13 59 00
Running the Mocha task in next-static after this change:
Screenshot 2024-05-20 at 13 59 11
And here is what the output looks like when mocha is run directly instead. Note the matching amount of whitespace.
Screenshot 2024-05-20 at 14 09 56

Checklist:

  • My branch has been rebased onto the latest commit on main (don't merge main into your branch)
  • My commit messages are conventional commits, for example: feat(circleci): add support for nightly workflows, fix: set Heroku app name for staging apps too

This partially reverts d1374d1, which I think was a mistake as we
already remove the EOL character normally added by winston, and we skip
appending a newline character to messages if it has a `process`
attribute. So it meant that the only newlines that would be preserved
were ones that happened to not be at the end (or start) of a stream
flush.
@ivomurrell ivomurrell requested a review from a team as a code owner May 20, 2024 13:10
Because we were declaring a regex within a template literal we needed to
escape the backslash in the `\s` whitespace meta group. I we don't, the
backslash is parsed as an escape character for the template literal, not
the regex, and is replaced with a literal `s` as `\s` is not a valid
escape sequence. This means the regex would search for an `s` instead of
whitespace. This doesn't affect the unescaped `\n` as the escaped `\n`
and the literal `0x0A` ASCII character are (roughly) equivalent in a
regex.

Instead of fixing the incorrect `\s`, let's remove it entirely and not
trim whitespace characters, just newlines, as I'm not sure we actually
want to strip indentation from hooked console logging.
@ivomurrell ivomurrell merged commit 1482c8a into next May 22, 2024
14 checks passed
@ivomurrell ivomurrell deleted the fix-subprocess-logging branch May 22, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants