triggerdotdev/trigger.dev

bug: Cannot get final name for export 'SEMATTRS_HTTP_STATUS_CODE'

Opened this issue · 7 comments

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/sdk@3.3.6 I started getting the following error when building a NextJS 14 project:

./node_modules/.pnpm/@trigger.dev+sdk@3.3.6_zod@3.21.4/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/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
./node_modules/.pnpm/@trigger.dev+sdk@3.3.6_zod@3.21.4/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/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js

Downgrading back to @trigger.dev/sdk@3.2.1 allows the build to complete successfully.

Reproduction repo

n/a

To reproduce

  1. Install @trigger.dev/sdk@3.2.1
  2. Create a task triggered in a Server Action
  3. Run pnpm build on next@14.0.4 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.

@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.

Same here - any resolutions?

@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

@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?

+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",

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

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