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

[NextJS] It does not work on the client. The "if (typeof fetch === "function")" part appears to be missing. #2091

Closed
n-guitar opened this issue May 30, 2022 · 1 comment
Labels
community question Further information is requested

Comments

@n-guitar
Copy link

n-guitar commented May 30, 2022

Expected behaviour

I would like to use "dd-tarce" in my "next" application.
At init, an error occurs and the application does not start.
I don't need the "fs api" because I don't use it.
What should I do in this case?
※ I understand that fs only works on the server side.

It appears to be slipping through the "if (typeof fetch === "function") " part.

if (typeof fetch === "function") {
    ・・・
} else {
// Node version of reading a wasm file into an array buffer.
const fs = require("fs"); // Error here
const path = require("path");

I thought the library was using "fetch" feature detection to determine if the current environment is a browser or node environment, but it doesn't appear to be working.
Is the above understanding correct?

The latest "source-map" appears to have fixed this.
mozilla/source-map#349

Actual behaviour
Steps to reproduce

import tracer from 'dd-trace';
tracer.init();
$ next dev
・・・
error - ./node_modules/@datadog/pprof/node_modules/source-map/lib/read-wasm.js:20:0
Module not found: Can't resolve 'fs'
Import trace for requested module:
./node_modules/@datadog/pprof/node_modules/source-map/lib/source-map-consumer.js
./node_modules/@datadog/pprof/node_modules/source-map/source-map.js
./node_modules/@datadog/pprof/out/src/sourcemapper/sourcemapper.js
./node_modules/@datadog/pprof/out/src/index.js
./node_modules/dd-trace/packages/dd-trace/src/profiling/profiler.js
./node_modules/dd-trace/packages/dd-trace/src/profiling/index.js
./node_modules/dd-trace/packages/dd-trace/src/profiler.js
./node_modules/dd-trace/packages/dd-trace/src/proxy.js
./node_modules/dd-trace/packages/dd-trace/index.js
./node_modules/dd-trace/index.js
./cl-common/index.ts
./pages/_app.tsx

Environment

  • Operation system:
    Red Hat Enterprise Linux release 8.2 (Ootpa)
    4.18.0-193.el8.x86_64

  • Node.js version:
    node: v16.13.1

  • Tracer version:
    dd-trace 2.7.1

  • Relevant library versions:
    yarn: 1.22.17

@n-guitar n-guitar added the bug Something isn't working label May 30, 2022
@rochdev rochdev added question Further information is requested community and removed bug Something isn't working labels May 30, 2022
@rochdev
Copy link
Member

rochdev commented May 30, 2022

This library doesn't support running in the browser. I would recommend looking into our browser SDK for RUM to get visibility in the browser.

@rochdev rochdev closed this as completed May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants