vercel / otel

OTEL tracing for Vercel
https://vercel.com/docs/observability/otel-overview
37 stars 9 forks source link

Error: An error occurred while loading instrumentation hook: Cannot find module 'os' #91

Open newcworld opened 5 months ago

newcworld commented 5 months ago
⚠ ./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js
Error: An error occurred while loading instrumentation hook: Cannot find module 'os'
    at webpackEmptyContext (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/instrumentation.js:22:10)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:12687)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:29503)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:29991)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:30305)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:43728)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:60086)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:21:20565)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:20:832)
    at eval (webpack-internal:///(instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js:33:45327)
    at (instrument)/./node_modules/.pnpm/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq/node_modules/@vercel/otel/dist/node/index.js (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/vendor-chunks/@vercel+otel@1.8.3_@opentelemetry+api-logs@0.46.0_@opentelemetry+api@1.9.0_@opentelemetry+ins_afxcmrvzguz46bycbb3njvxqfq.js:20:1)
    at __webpack_require__ (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(instrument)/./src/instrumentation.ts:5:70)
    at (instrument)/./src/instrumentation.ts (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/instrumentation.js:62:1)
    at __webpack_require__ (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/webpack-runtime.js:33:42)
    at __webpack_exec__ (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/instrumentation.js:72:39)
    at /Users/aonsx/WebstormProjects/lobe-chat/.next/server/instrumentation.js:73:287
    at __webpack_require__.X (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/webpack-runtime.js:116:21)
    at /Users/aonsx/WebstormProjects/lobe-chat/.next/server/instrumentation.js:73:47
    at Object.<anonymous> (/Users/aonsx/WebstormProjects/lobe-chat/.next/server/instrumentation.js:76:3)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at mod.require (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:179:18)
    at DevServer.runInstrumentationHookIfAvailable (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/dev/next-dev-server.js:436:51)
    at async Span.traceAsyncFn (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/trace/trace.js:154:20)
    at async DevServer.prepareImpl (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/dev/next-dev-server.js:214:9)
    at async NextServer.prepare (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/next.js:161:13)
    at async initializeImpl (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/lib/render-server.js:98:5)
    at async initialize (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/lib/router-server.js:423:22)
    at async Server.<anonymous> (/Users/aonsx/WebstormProjects/lobe-chat/node_modules/.pnpm/next@14.2.3_@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/lib/start-server.js:249:36) {
  code: 'MODULE_NOT_FOUND'
}
mabreuortega commented 4 months ago

Same thing happening to me :-(

jakeinflab commented 4 months ago

same issue for me :(

Pederzh commented 3 days ago

I had this problem, too. I resolved it by adding "@vercel/otel" to the serverComponentsExternalPackages list in Next.js configuration.

In next.config.ts add:

experimental: {,
  serverComponentsExternalPackages: [
    "@vercel/otel"
   ]
}

This change tells Next.js to treat @vercel/otel as an external package in server components, which should resolve the critical dependency warning.