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

remix @sentry/profiling-node #11992

Open
3 tasks done
jasonloeve opened this issue May 13, 2024 · 3 comments
Open
3 tasks done

remix @sentry/profiling-node #11992

jasonloeve opened this issue May 13, 2024 · 3 comments

Comments

@jasonloeve
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/remix

SDK Version

7.114.0

Framework Version

^18.2.0

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Follow the docs at https://docs.sentry.io/platforms/javascript/guides/remix/profiling/#prerequisites to setup profiling in a new remix application (Hydrogen).
  2. Run npm dev / build etc (Node v20.12.1, npm v10.5.0)

Expected Result

The application to build out

Actual Result

Receiving the following errors

`✘ [ERROR] Could not resolve "os"

node_modules/@sentry/profiling-node/lib/index.js:3:19:
  3 │ const os = require('os');
    ╵                    ~~~~

The package "os" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "path"

node_modules/@sentry/profiling-node/lib/index.js:4:21:
  4 │ const path = require('path');
    ╵                      ~~~~~~

The package "path" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "worker_threads"

node_modules/@sentry/profiling-node/lib/index.js:8:31:
  8 │ const worker_threads = require('worker_threads');
    ╵                                ~~~~~~~~~~~~~~~~

The package "worker_threads" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "child_process"

node_modules/@sentry/profiling-node/node_modules/detect-libc/lib/detect-libc.js:6:29:
  6 │ const childProcess = require('child_process');
    ╵                              ~~~~~~~~~~~~~~~

The package "child_process" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

✘ [ERROR] Could not resolve "fs"

node_modules/@sentry/profiling-node/node_modules/detect-libc/lib/filesystem.js:6:19:
  6 │ const fs = require('fs');
    ╵                    ~~~~

The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
`

@mydea
Copy link
Member

mydea commented May 13, 2024

Can you share your init code, as well as in which file you put it? This sounds like you are loading nodeProfilingIntegration in entry.client.js or something along these lines!

@jasonloeve
Copy link
Author

jasonloeve commented May 14, 2024

Hey @mydea ,

So Im working with Shopify Hydrogen (Remix)

entry.client.tsx

import * as Sentry from '@sentry/remix';
import {RemixBrowser, useLocation, useMatches} from '@remix-run/react';
import {startTransition, StrictMode, useEffect} from 'react';
import {hydrateRoot} from 'react-dom/client';

Sentry.init({
  dsn: 'https://xxxxxxxxxxxxx@xxxxxxxxxxxxxxx.ingest.us.sentry.io/xxxxxxxxxxxxxxx',
  tracesSampleRate: 1.0,
  profilesSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1,

  integrations: [
    Sentry.browserTracingIntegration({
      useEffect,
      useLocation,
      useMatches,
    }),
    Sentry.replayIntegration(),
    Sentry.browserProfilingIntegration(),
  ],
});

startTransition(() => {
  hydrateRoot(
    document,
    <StrictMode>
      <RemixBrowser />
    </StrictMode>,
  );
});

entry.server.tsx

import * as Sentry from '@sentry/remix';
import {nodeProfilingIntegration} from '@sentry/profiling-node';
import type {EntryContext} from '@shopify/remix-oxygen';
import {RemixServer} from '@remix-run/react';
import isbot from 'isbot';
import {renderToReadableStream} from 'react-dom/server';
import {createContentSecurityPolicy} from '@shopify/hydrogen';

export function handleError(error, {request}) {
  Sentry.captureRemixServerException(error, 'remix.server', request);
}

Sentry.init({
  dsn: 'https://xxxxxxxxxxxxx@xxxxxxxxxxxxxxx.ingest.us.sentry.io/xxxxxxxxxxxxxxx',
  // debug: true,
  tracesSampleRate: 1.0,
  profilesSampleRate: 1,
  integrations: [nodeProfilingIntegration()],
});

.......................

@lforst
Copy link
Member

lforst commented May 14, 2024

@jasonloeve I lack a bit of knowledge on hydrogen but I think it does generally not run on Node.js but on a worker runtime instead (at least when looking at this Shopify/hydrogen#1535). It running on a worker runtime means that most of the Node.js API is not available. As of now, our SDK is not cut out for this. Is this only a problem when using the nodeProfilingIntegration() or do you get similar errors after removing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants