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

EMFILE: too many open files, uv_resident_set_memory in _updateContext #9507

Closed
3 tasks done
ghost opened this issue Nov 9, 2023 · 4 comments
Closed
3 tasks done

EMFILE: too many open files, uv_resident_set_memory in _updateContext #9507

ghost opened this issue Nov 9, 2023 · 4 comments
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@ghost
Copy link

ghost commented Nov 9, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.77.0

Framework Version

Next 14.0.1

Link to Sentry event

https://sentry.io/organizations/thinkaidium/issues/4598335869/?project=4504118550528000&referrer=github_integration

SDK Setup

client:

init({
    dsn: SENTRY_DSN,
    environment: process.env['ENVIRONMENT'],
    tracesSampleRate: 0.1,

    // This sets the sample rate to be 10%. You may want this to be 100% while
    // in development and sample at a lower rate in production
    replaysSessionSampleRate: 0.1,
    // If the entire session is not sampled, use the below sample rate to sample
    // sessions when an error occurs.
    replaysOnErrorSampleRate: 1.0,
    integrations: [new Replay()],
  });

edge:

init({
    dsn: SENTRY_DSN,
    environment: process.env['ENVIRONMENT'],
    tracesSampleRate: 0.1,
  });

server:

init({
    dsn: SENTRY_DSN,
    environment: process.env['ENVIRONMENT'],
    tracesSampleRate: 0.1,
  });

Steps to Reproduce

I'm not sure. You can get the call stack from the sentry link attached.

node:internal/process/per_thread in process.memoryUsage at line 172:5
/var/task/node_modules/@sentry/node/cjs/integrations/context.js in Context._updateContext at line 76:41
/var/task/node_modules/@sentry/node/cjs/integrations/context.js in Context.addContext at line 56:33

After a bit of a research from my side, I see that the community uses 'graceful-fs'/'node-fs-extra' instead of 'fs' to prevent EM File errors.

Expected Result

No errors?

Actual Result

Throws this error.

@ghost ghost added the Type: Bug label Nov 9, 2023
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 9, 2023
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Nov 9, 2023
@lforst
Copy link
Member

lforst commented Nov 9, 2023

Hm, the error was thrown on this line:

contexts.app.app_memory = process.memoryUsage().rss;

I don't know if this is fixable from within the SDK. To me it looks like either you or the hosting provider had too many FDs open on the system.

@ghost
Copy link
Author

ghost commented Nov 13, 2023

From some online research, I saw that 'fs' doesn't take care of "EM file errors", which is seen here. I see that you're using 'fs' in multiple places to deal with files. Have you considered changing it to 'graceful-fs' or 'node-fs-extra'?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 13, 2023
@lforst
Copy link
Member

lforst commented Nov 13, 2023

@misuvii we generally steer away from dependencies, especially in low-level-ish SDKs like @sentry/node. The thing is, in the line we threw in, we didn't even use fs. It's a node internal API that threw this error. I wouldn't know how to fix this except for try catching here, however that feels weird considering this is just node internal API that should generally not throw in the first place.

@AbhiPrasad
Copy link
Member

Closing this PR as cleanup, we've made many adjustments in the latest version of the SDK. If the issue is still happening after upgrading the SDK to the latest version, please open a new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug
Projects
Archived in project
Archived in project
Development

No branches or pull requests

2 participants