vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.02k stars 26.99k forks source link

NextJS build error #72864

Open Abukodonosor opened 2 hours ago

Abukodonosor commented 2 hours ago

Verify canary release

Provide environment information

*** Environment: dev! Building application context ****

Operating System:
  Platform: linux
  Arch: x64
  Version: #48~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  7 11:24:13 UTC 2
  Available memory (MB): 31806
  Available CPU cores: 8
Binaries:
  Node: 20.12.1
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: 15.0.3
  react: 19.0.0-rc-1631855f-20241023
  react-dom: 19.0.0-rc-1631855f-20241023
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which example does this report relate to?

NextJS build with 'reflect-metadata'

What browser are you using? (if relevant)

n/a (server-side-rendering)

How are you deploying your application? (if relevant)

no, but will live in AWS

Describe the Bug

✓ Linting and checking validity of types Collecting page data .Error: Failed to collect configuration for /support at (/home/oblong/Client/next-playground-rc/nodemodules/.pnpm/next@15.0.3@babel+core@7.26.0_react-dom@19.0.0-rc-1631855f-20241023_react@19.0.0-rc-1631855f_7gxsathfvsavkjwkzbbismtxmu/node_modules/next/dist/build/utils.js:1131:23) at async Span.traceAsyncFn (/home/oblong/Client/next-playground-rc/nodemodules/.pnpm/next@15.0.3@babel+core@7.26.0_react-dom@19.0.0-rc-1631855f-20241023_react@19.0.0-rc-1631855f_7gxsathfvsavkjwkzbbismtxmu/node_modules/next/dist/trace/trace.js:153:20) { [cause]: Error: Service not found: v at O.resolve (/home/oblong/Client/next-playground-rc/workspace/platform/.next/server/app/(static)/support/page.js:2:17953)

Expected Behavior

I run the program in the dev environment and everything works file.

        "dev-debug": "NODE_OPTIONS='--inspect' next dev --turbo",

Then I start the production build and the error that I show above is present.

After detailed investigation I have found that problem is laying in the 'reflact-metadata' -> and how next15 works with it.

'use server';

import { DepProviders } from '@homestory/core/src/_base/depInj/decorators';
import { SupportFormValidationUseCase } from '@homestory/core/src/useCase/SupportFormValidationUseCase';
import { ResultStatus } from '@homestory/core/src/_base/util';
import { formStatus, SupportForm, SupportFormAction } from '@/types/form.types';
import container from '@/lib/coreDep';

export async function supportFormAction(
    _: SupportFormAction,
    formData: FormData,
    injector = container
): Promise<SupportFormAction> {
    const rawFormData: SupportForm = {
        fullName: formData.get('full name') as string,
        phone: formData.get('phone') as string,
        email: formData.get('email') as string,
        message: formData.get('message') as string
    };

    const supportFormAction = injector.resolve<SupportFormValidationUseCase>(DepProviders.SupportFormValidationUseCase);
    const { status, message, data } = await supportFormAction.execute(rawFormData);

    if (status == ResultStatus.ERROR) {
        return {
            status: formStatus.ERROR,
            errors: {
                ...data
            },
            initialValues: rawFormData
        };
    }

    // revalidatePath('/support');

    return {
        status: formStatus.SUCCESS,
        errors: null,
        initialValues: rawFormData
    };
}

Dep container works, but when i want to use the Repository code which uses


@injectable(InjectableTypeSymbols.REPOSITORY)
export class BankRepositoryImpl implements BankRepository {
    private bankApiAdapter: BankApiAdapterService1<AccountDTO>;

    constructor(@inject(DepProviders.BankApiAdapterService1) bankApiAdapter: BankApiAdapterService1<AccountDTO>) {
        this.bankApiAdapter = bankApiAdapter;
    }

    async getAccountDetails(accountId: string): Promise<Result<Account>> {
        try {
            const result = await this.bankApiAdapter.getAccountDetails(accountId);

            if (!isSuccess(result)) {
                throw new Error(`The getAccountDetails failed with status ${result.status}`);
            }

            const account = new AccountEntity(result.data.id, result.data.name, result.data.balance, result.data.currency);

            return ResultSuccess(account, 'Account details retrieved successfully!');
        } catch (error) {
            return ResultError(error, 'Failed to get Account Details from BankApiAdapter');
        }
    }

The next turbo build give me this error.

Which steps i should take to enable this lib to work with next eco-system.

To Reproduce

Pls make the dependency container using the "reflect-metadata": "^0.2.2",

I can be of help and pass you some code regarding this.

I am using pnpm and also have workspaces in the app to split the concerns.

Abukodonosor commented 2 hours ago

@leerob

Can you pls take a look to it?

(Could transpailer/babel can be usefully with this kind of issue?)