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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console buffer not flushed before process exits #8421

Closed
dandv opened this issue May 5, 2019 · 6 comments
Closed

Console buffer not flushed before process exits #8421

dandv opened this issue May 5, 2019 · 6 comments

Comments

@dandv
Copy link
Contributor

dandv commented May 5, 2019

馃悰 Bug Report

Because there's no documented way to abort tests if setup in beforeAll fails (#6695), I tried to process.exit(). This works, but it turns out it's impossible to log any errors (which had lead to the setup failing).

To Reproduce

Run this test with or without circus:

beforeAll(() => {
  if ('something failed') {
    const e = 'here is the error message that is not logged';


    console.error('Error:', e);
    process.exit(1);
  }
});

test('your test suite must contain at least one test', () => {
});

Expected behavior

I expect the console.error output to be visible in the terminal. Instead, I see this:

image

Link to repl or repo (highly encouraged)

https://repl.it/repls/JuniorJumboOmnipage

@SimenB
Copy link
Member

SimenB commented May 6, 2019

This is expected behaviour. You call process.exit, so it exits. Not sure if it makes sense for us to try to do any more work here.

Seems like we might have a bug with failing lifecycle hooks though, need to investigate

@brandonchinn178
Copy link
Contributor

This is expected behaviour. You call process.exit, so it exits. Not sure if it makes sense for us to try to do any more work here.

Not sure this answers the original issue. The issue is that, as a developer, I would expect that console.error displays the message to the console before the process exits. Is that not expected behavior?

@dandv
Copy link
Contributor Author

dandv commented Apr 19, 2020

@brandonchinn178: thanks for reviving this. I'm not super familiar with Node buffering and internals, but it seems there's generally a problem with logging anything before process.exit(). See for example this bug in Winston and this one in the Bristol logger.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants