Skip to content

[BUG][@opentelemetry] Could not resolve "../platform"  #219

@NayamAmarshe

Description

@NayamAmarshe

Describe the bug

I'm using firebase + Next.js 14 API Route Handlers. I've added force-dynamic to all the required routes and pages but when I do npm run preview:worker it throws the following error:

> dev:worker
> wrangler dev --port 8771


 ⛅️ wrangler 3.99.0
-------------------

Using vars defined in .dev.vars
Your worker has access to the following bindings:
- Vars:
  - NEXTJS_ENV: "(hidden)"
  - NODE_ENV: "(hidden)"
[wrangler:inf] Ready on http://localhost:8771
▲ [WARNING] Suspicious assignment to defined constant "process.env.NODE_ENV" [assign-to-define]

    .open-next/server-functions/default/handler.mjs:32217:4:
      32217 │     process.env.NODE_ENV = "production";~~~~~~~~~~~~~~~~~~~~

  The expression "process.env.NODE_ENV" has been configured to be replaced with a constant using the "define" feature. If this expression is supposed to be a compile-time constant, then it doesn't make sense to assign to it here. Or if this expression is supposed to change at run-time, this "define" substitution should be removed.



✘ [ERROR] Build failed with 1 error:

  ✘ [ERROR] Could not resolve "../platform"
  
  
  .open-next/server-functions/default/node_modules/@opentelemetry/api/build/src/internal/global-utils.js:19:27:
        19 │ const platform_1 = require("../platform");
           ╵                            ~~~~~~~~~~~~~
  
  


▲ [WARNING] Suspicious assignment to defined constant "process.env.NODE_ENV" [assign-to-define]

    .open-next/server-functions/default/handler.mjs:32217:4:
      32217 │     process.env.NODE_ENV = "production";
            ╵     ~~~~~~~~~~~~~~~~~~~~

  The expression "process.env.NODE_ENV" has been configured to be replaced with a constant using the "define" feature. If this expression is supposed to be a compile-time constant, then it doesn't make sense to assign to it here. Or if this expression is supposed to change at run-time, this "define" substitution should be removed.


🪵  Logs were written to "/Users/macbook-air/Library/Preferences/.wrangler/logs/wrangler-2025-01-01_00-21-52_196.log"

Steps to reproduce

  1. Next.js 14 project with API route handlers and a dynamic page.
  2. Use firebase db/auth on both static and dynamic routes.
  3. Try running npm run preview:worker

Expected behavior

It should start the dev server

@opennextjs/cloudflare version

0.3.3

Wrangler version

3.99.0

next info output

$ npx next info         

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.2.0: Fri Dec  6 18:40:14 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: 1.22.21
  pnpm: 8.14.3
Relevant Packages:
  next: 14.2.21 // An outdated version detected (latest is 15.1.3), upgrade is highly recommended!
  eslint-config-next: 14.2.21
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.7.2
Next.js Config:
  output: N/A
 ⚠ An outdated version detected (latest is 15.1.3), upgrade is highly recommended!
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions