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

bug: Cannot get final name for export 'SEMATTRS_HTTP_STATUS_CODE' #1547

Open
rafalzawadzki opened this issue Dec 10, 2024 · 7 comments
Open

Comments

@rafalzawadzki
Copy link

Provide environment information

System:
OS: macOS 14.4
CPU: (12) arm64 Apple M2 Max
Memory: 1.51 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.4.0 - ~/.nvm/versions/node/v21.4.0/bin/node
Yarn: 1.22.21 - /opt/homebrew/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v21.4.0/bin/npm
pnpm: 9.14.2 - ~/Library/pnpm/pnpm
bun: 1.0.6 - ~/.bun/bin/bun

Describe the bug

After upgrading to @trigger.dev/[email protected] I started getting the following error when building a NextJS 14 project:

./node_modules/.pnpm/@[email protected][email protected]/node_modules/@trigger.dev/sdk/dist/esm/v3/retry.js + 6 modules
Cannot get final name for export 'SEMATTRS_HTTP_STATUS_CODE' of ./node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@trigger.dev/sdk/dist/esm/v3/retry.js + 6 modules
Cannot get final name for export 'SEMATTRS_HTTP_STATUS_CODE' of ./node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js

Downgrading back to @trigger.dev/[email protected] allows the build to complete successfully.

Reproduction repo

n/a

To reproduce

  1. Install @trigger.dev/[email protected]
  2. Create a task triggered in a Server Action
  3. Run pnpm build on [email protected] project

Additional information

I tried following suggestions in similar issues related to NextJS:

Adding the following to next.config.js:

serverComponentsExternalPackages: [
      '@trigger.dev',
      '@trigger.dev/sdk',
      '@opentelemetry',
      '@opentelemetry/semantic-conventions'
 ]

Unfortunately to no avail.

@ericallam
Copy link
Member

@rafalzawadzki Is this happening in a monorepo, or just a regular repo? Do you possibly have code that reproduces this? I'm unable to myself so far.

@techjason
Copy link

Same here - any resolutions?

@rafalzawadzki
Copy link
Author

@ericallam it's a standard Next repo (not monorepo, no turbo etc)

unfortunately can't provide the code

@techjason downgrading trigger was the workaround for now

@ericallam
Copy link
Member

@rafalzawadzki I'm guessing in the "To reproduce" steps above you meant to say "Install @trigger.dev/sdk@latest"?

@techjason any chance you have a repo that can reproduce this? Could you provide any more details on your stack?

@ming1in
Copy link

ming1in commented Dec 16, 2024

+1 same issue here on the following version on a nextjs application

    "@trigger.dev/build": "3.3.7",
    "@trigger.dev/sdk": "3.3.7",
    "trigger.dev": "^3.0.12",

@ericallam
Copy link
Member

@ming1in any chance you could share a minimal repo that reproduces this?

@ericallam
Copy link
Member

Okay I've managed to reproduce this bug and here's what I found:

Between 14.0.0 and 14.2.7, there is a Next.js build issue that can occur in certain circumstances:

  1. Call a server action from a client component
  2. The server action imports a named function (for example, mockTriggerHelloWorldTask) from another file (let's call it triggerWrapper.ts)
  3. triggerWrapper.ts imports a Trigger.dev task defined in another file.
  4. The mockTriggerHelloWorldTask function does NOT make use of the Trigger.dev that was imported.

This will (for some reason) cause builds to fail with the above error (or one very similar). There are two fixes I've found so far for this:

  1. Upgrade to Next.js 14.2.8 or later
  2. OR, add this to your next config:
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    // Add this line to fix the "Cannot get final name for export" error
    // Alternatively, you can upgrade to Next.js 14.2.8 or later
    serverComponentsExternalPackages: ["@trigger.dev/sdk"],
  },
};

export default nextConfig;

@rafalzawadzki @techjason @rafalzawadzki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants