Skip to content

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

Closed
@xddq

Description

@xddq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions