Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Unhandled "StopProfiling: Stopping Sentry profile did not return a profile" errors #196

@tomgrossman

Description

@tomgrossman

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

SDK Version

@sentry/* - 7.66.0, @sentry/profiling-node - 1.2.0

Link to Sentry event

https://guardz.sentry.io/issues/4452503110/events/9e36fc80170045e191ab84ebfb12db22/?project=6674202

What environment is your node script running in?

TS - Node.js, Nest.js, Express (all latest)

How is your code deployed and bundled?

dockerfile, installing and building

Steps to Reproduce

For some reason it doesn't reproduce locally, only in prod.

init:

import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';
import { RewriteFrames } from '@sentry/integrations';
import { ProfilingIntegration } from '@sentry/profiling-node';

Sentry.init({
      dsn: xxx,
      environment:'production',
      integrations: [
        new RewriteFrames({
          root: '/app',
        }),
        new Sentry.Integrations.Http({ tracing: true }),
        new Tracing.Integrations.Express({
          app: httpAdapter.getInstance(),
        }),
        new ProfilingIntegration(),
      ],
      tracesSampler: (samplingContext) => {
        if (samplingContext.request?.url?.includes('/health')) {
          return 0;
        }

        return 0.2;
      },
      profilesSampleRate: 1.0,
    });

worker (short version):

import * as Sentry from '@sentry/node';
import { OnWorkerEvent } from '@nestjs/bullmq';
import { Job } from 'bullmq';

export default class EventListenerWorker{

  private transaction: Sentry.Transaction;

  async process(job: Job): Promise<unknown> {
    return { success: true}
  }

  @OnWorkerEvent('active')
  onActive(job: Job) {
    this.transaction = Sentry.startTransaction({ op: 'worker', name: job.queueName, sampled: true });
  }

  @OnWorkerEvent('completed')
  async onCompleted() {
    this.transaction.finish();
  }

  @OnWorkerEvent('failed')
  async onFailed() {
    this.transaction.finish();
  }
}

Expected Result

end the transaction successfully.

Actual Result

We are getting lots of unhandled errors:

Error: StopProfiling: Stopping Sentry profile did not return a profile.                                                                                                                                                                                                    │
     at Object.stopProfiling (/app/node_modules/@sentry/profiling-node/lib/index.js:17507:39)                                                                                                                                                                               │
     at stopTransactionProfile (/app/node_modules/@sentry/profiling-node/lib/index.js:17866:39)                                                                                                                                                                             │
     at Timeout._onTimeout (/app/node_modules/@sentry/profiling-node/lib/index.js:17980:29)                                                                                                                                                                                 │
     at listOnTimeout (node:internal/timers:569:17)                                                                                                                                                                                                                         │
     at process.processTimers (node:internal/timers:512:7) {                                                                                                                                                                                                                │
   code: 'NAPI_ERROR'                                                                                                                                                                                                                                                       │
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions