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

Azure function - A system error occurred: uv_uptime returned EPERM (operation not permitted) #8202

Closed
3 tasks done
xddq opened this issue May 24, 2023 · 1 comment · Fixed by #8206
Closed
3 tasks done

Comments

@xddq
Copy link

xddq commented May 24, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.53.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Sentry.init({
dsn: 'the-dsn-here',
tracesSampleRate: 1.0,
environment: process.env.ENVIRONMENT,
});

Steps to Reproduce

Problem:

Using nodejs with 7.53.0 (and probably older versions, tested with 7.50) for azure functions crashes with a sentry package specific error when trying to capture an exception.

How to reproduce

  • Deploy any code containing the sentry 7.53.0 package to azure functions using nodejs and the given/"normal" sentry.init.
  • Call Sentry.captureException(error) and await Sentry.flush(2000)

Azure Behaviour for os.uptime

It seems to me that azure functions now have os.uptime defined but one is still not allowed to call the function.
I did a quick print and got:

grafik

and in sentry:

grafik

with the code:

const main = async (context: Context, myBlob: any): Promise<void> => {
  context.log('logging os.uptime:', os.uptime);
  context.log('logging os.uptime():', os.uptime());
...

Fix?

a) Somehow have to fix the check inside @sentry\node\cjs\integrations\context.js in getDeviceContext at line 183:34. It seems that os.uptime is defined in azure function, but calling it still yields the system error. Therefore the current check is not viable
The code snippet:

function getDeviceContext(deviceOpt) {
  const device = {};

  // os.uptime or its return value seem to be undefined in certain environments (e.g. Azure functions).
  // Hence, we only set boot time, if we get a valid uptime value.
  // @see https://github.com/getsentry/sentry-javascript/issues/5856
  const uptime = os.uptime && os.uptime();
  if (typeof uptime === 'number') {
    device.boot_time = new Date(Date.now() - uptime * 1000).toISOString();
  }

b) Use the fix provided by @joelcollyer here by adding the device: false. E.g.

Sentry.init({
  dsn: 'dsn-here',
  tracesSampleRate: 1.0,
  environment: process.env.ENVIRONMENT,
  integrations: [new Sentry.Integrations.Context({ device: false })],
});

Expected Result

The error that was passed to Sentry.captureException() is captured in sentry

Actual Result

A permission error based on the sentry internal code is captured in sentry

@lforst
Copy link
Member

lforst commented May 24, 2023

Thanks for raising this!

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

Successfully merging a pull request may close this issue.

2 participants