Skip to content

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

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

Closed
NayamAmarshe opened this issue Jan 1, 2025 · 13 comments · Fixed by #302
Closed

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

NayamAmarshe opened this issue Jan 1, 2025 · 13 comments · Fixed by #302
Assignees
Labels
bug Something isn't working

Comments

@NayamAmarshe
Copy link

NayamAmarshe commented Jan 1, 2025

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

@dario-piotrowicz
Copy link
Contributor

Thanks a bunch for the issue @NayamAmarshe, I also noticed this issue but I wasn't sure if it was specific to the app I was working on, good to know that it's a general issue

It would really be great to have a minimal repro for this 😓

anyways I'll look into this 🙂

@dario-piotrowicz

This comment was marked as outdated.

@shahadpichen
Copy link

Hi, I'm currently facing the same issue with the 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");

Any updates or workarounds would be greatly appreciated. Thanks in advance!

@vicb
Copy link
Contributor

vicb commented Jan 8, 2025

What help us help you it's if you can submit a repository containing a minimal repro for the issue.
Thanks

@shahadpichen
Copy link

Thanks for the response @vicb ! I've created a minimal repository for the issue.

You can find it here: https://github.com/shahadpichen/opentelemetry-issue.

Please let me know if you need any further details.

@RickyRAV
Copy link

hi there, ive come across the same issue, and we have similar tech stacks, the problem is caused by "drizzle-orm": "^0.38.3", because its using @opentelemetry/api, found it out by running: npm ls @opentelemetry/api
maybe this helps somehow

@vicb
Copy link
Contributor

vicb commented Jan 16, 2025

Image

@Nopsled
Copy link

Nopsled commented Jan 17, 2025

Also got same issue with this working with trigger.dev. Solved it like Aries with removing all dependencies in lockfile and used npm ci (instead of npm i). However I assume this means that I need to patch the lock-file each time I install a new package.

@vicb Is there any possibility to resolve this by using some older version of the adapter?

@vicb
Copy link
Contributor

vicb commented Jan 29, 2025

Thanks for the repro @shahadpichen.

I now understand how this happen, I only need to figure out why and then the proper fix.

A simple patch of global-utils.js fixes that:

-const platform_1 = require("../platform");
-const version_1 = require("../version");
-const semver_1 = require("./semver");
+const platform_1 = require("../platform/index.js");
+const version_1 = require("../version.js");
+const semver_1 = require("./semver.js");

@vicb
Copy link
Contributor

vicb commented Jan 29, 2025

A quick way to unblock ppl here is using:

WRANGLER_BUILD_CONDITIONS="" WRANGLER_BUILD_PLATFORM="node" pnpm wrangler dev
WRANGLER_BUILD_CONDITIONS="" WRANGLER_BUILD_PLATFORM="node" pnpm wrangler deploy

ref: https://opennext.js.org/cloudflare/troubleshooting#my-app-fails-to-build-when-i-import-a-specific-npm-package

We'll work on a proper fix in the coming days

@vicb
Copy link
Contributor

vicb commented Jan 29, 2025

You can find it here: https://github.com/shahadpichen/opentelemetry-issue.

Can I copy your repo into examples/bugs/gh-219 as a test for the fix?

i.e. does it contain any code that you do not want shared in the OpenNext repo?

@vicb
Copy link
Contributor

vicb commented Jan 30, 2025

Hopefully #302 should fix the issue, you can try by installing the adapter at https://pkg.pr.new/@opennextjs/cloudflare@302

Please report your experiences,

Thanks!

@shahadpichen
Copy link

You can find it here: https://github.com/shahadpichen/opentelemetry-issue.

Can I copy your repo into examples/bugs/gh-219 as a test for the fix?

i.e. does it contain any code that you do not want shared in the OpenNext repo?

Yah sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
6 participants