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

Can't catch exception thrown inside process.nextTick callback #836

Open
origin-yaropolk opened this issue Aug 8, 2023 · 7 comments
Open

Comments

@origin-yaropolk
Copy link

Describe the bug
If process.nextTick's callback throws exception, it can be catched neither by try...catch block nor .catch callback

To Reproduce
For example:
add exception inside mem() function here
like this

function mem(callback) {

  return new Promise((resolve) => {
    process.nextTick(() => {
    throw new Error('test');
   ...

and then try to catch like

try {
    await mem();
}

or
mem().catch(err => console.log(err));
it won't be catched. It received only in process.on('uncaughtException')

Expected behavior
It must be catched

Environment (please complete the following information):

  • systeminformation package version: 5.18.4
  • OS: macOS, windows, linux
  • Hardware ...

Additional context
Some of my users faced with problem - while collecting mem() info it throws exception, that i cant catch. Unfortunately, I can't provide you any stack trace to investigate the reason, caused exeption. I only know that they see write EPIPE error message.

@origin-yaropolk
Copy link
Author

I think exceptions inside callback must be explicitly catched and then reject promise

@sebhildebrandt
Copy link
Owner

@origin-yaropolk thank you for reporting. I get the point, providing a fix for it. Just curious, can you tell me more about the platforms and OS distro/version where this happens? As I did not got any complains here for years, I would like to know more about this ;-)

@origin-yaropolk
Copy link
Author

Sure.
Node version is 16.16.0
Most affected users have Windows 10.0.19045 and Windows 10.0.22621

This is hardware config for one of them

Operating System
			Windows 10 Pro 64-bit
		CPU
			Intel Core i7 4790 @ 3.60GHz	47 °C
			Haswell 22nm Technology
		RAM
			32.0GB Dual-Channel DDR3 @ 800MHz (9-9-9-24)

And his stack
image

Also, I found more relevant stack at sentry
image

@sebhildebrandt
Copy link
Owner

@origin-yaropolk interestingly this IS inside a try/catch ... so maybe you can give more details when / how often you are calling this.

@origin-yaropolk
Copy link
Author

I call mem() and processes() by timer every 30min

@sebhildebrandt
Copy link
Owner

sebhildebrandt commented Aug 9, 2023

@origin-yaropolk ... thank you!! Some more questions:

  • this happened only when calling mem()?
  • every time when calling mem()?
  • are both calls occur at the same time?
  • last question here: did you also tried it with the (still officially not documented) powerShellStart() and powerShellRelease() functions - which you could call on startup (windows only)?

Have a look at here: #616

@origin-yaropolk
Copy link
Author

  • Hard to say. It call together with another functions, but mem() is always called first
  • Mostly. If user have guaranteed crash by 30min timer, he also will crash while creating support ticket manually which also collect mem(). There is another very rare case, if user's session lasts for many hours (18 for example), the next call mem() will throw an exception
  • Yes, but, as I say early, mem() always called first
  • No didn't try. Realized just now that most of affected users have arabic (89%) lang. Also presents japanese, russian and en-US

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants