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] Upgrading from v3.26.3 to 3.28.0 results in Next.js build error #791

Open
paradoxloop opened this issue Jan 3, 2025 · 9 comments
Open

Comments

@paradoxloop
Copy link

Describe the bug
Next.js app upgrade from inngest v3.26.3 to 3.28.0 results in an error during build time.

Upgrading to 3.27.5 works so something is breaking in the 3.28.0 release.

If I had to guess this line in the new async feature is causing webpack some grief:

The reason this code might be touching webpack is that we reuse some utility functions across the app that throw Innegst NonRetriable errors. Commenting these out makes the error go away.

Expected behavior
There should be no build error.

Code snippets / Logs / Screenshots

[[next.js build command]]

Failed to compile.

node:async_hooks
Module build failed: UnhandledSchemeError: Reading from "node:async_hooks" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:401757
    at Hook.eval [as callAsync] (eval at create (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:13:26012)
    at Object.processResource (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:401682)
    at processResource (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:401544)
    at NormalModule.build (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:403572)
    at /Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:82055
    at NormalModule.needBuild (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:407670)
    at Compilation._buildModule (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:81772)
    at /Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:1332896
    at Hook.eval [as callAsync] (eval at create (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:6:1)
    at AsyncQueue._startProcessing (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:1332767)
    at AsyncQueue._ensureProcessing (/Users/[User]/Documents/projects/[Project]/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/webpack/bundle5.js:28:1332616)
    at process.processImmediate (node:internal/timers:491:21)

Import trace for requested module:
node:async_hooks
./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_@opentelemetry+_fkp3p6cb3wz33zqhetrs2mg65a/node_modules/inngest/components/execution/als.js
./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_@opentelemetry+_fkp3p6cb3wz33zqhetrs2mg65a/node_modules/inngest/components/execution/v1.js
./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_@opentelemetry+_fkp3p6cb3wz33zqhetrs2mg65a/node_modules/inngest/components/InngestFunction.js
./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_@opentelemetry+_fkp3p6cb3wz33zqhetrs2mg65a/node_modules/inngest/components/Inngest.js
./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_@[email protected]_@opentelemetry+_fkp3p6cb3wz33zqhetrs2mg65a/node_modules/inngest/index.js

System info (please complete the following information):

  • Next.js v14.2.19
  • Node v22.10.0
  • Typescript v5.7.2
  • pnpm v 9.71
Copy link

linear bot commented Jan 3, 2025

@jpwilliams
Copy link
Member

Hi @paradoxloop!

Where is inngest being used to cause this error?

Reading through vercel/next.js#28774, it seems this is usually expected if we're performing this import within client-side code.

@paradoxloop
Copy link
Author

@jpwilliams we have utility code that gets used both in backend and frontend. In a couple of places we are throwing the NonRetriableError error which is how we are ending up with Inngest code in the front end.

@jpwilliams
Copy link
Member

@paradoxloop Makes sense.

We do intentionally delay the importing of node:async_hooks to avoid cases like this, but I guess Webpack is being nosey and finding it ahead of time.

So only NonRetriableError is being imported and used in client-side code? I'd love to find a solution to this that doesn't require you changing any of your config!

@paradoxloop
Copy link
Author

@jpwilliams yes just NonRetriableError since all other Inngest specific code is sitting in the isolated workflow files that run each workflow.

@jpwilliams
Copy link
Member

@paradoxloop I can't seem to reproduce this just with importing the inngest lib within client code.

All the same, there's a small PR at #793 that may resolve the Webpack issue. Could you try that for me? You can install is using:

npm install inngest@pr-793

@paradoxloop
Copy link
Author

@jpwilliams Thanks for shipping an attempted fix. I just tried it and it does not resolve the issue. I will try to pu together a MVR in the next couple of days.

@iljapanic
Copy link

iljapanic commented Jan 16, 2025

I'm experiencing the same issue with 3.29.3,

Downgrading to 3.27.5 fixes the build.

Here is the components that triggers the error (redacted for clarity):

'use client'

import * as React from 'react';
import { inngest } from '@/lib/inngest/client'

export function OrganizationImporter() {

  const handleSubmit = async (e: React.FormEvent) => {
    try {
      await inngest.send({
        name: "organizations.bulk-import",
        data: {
          websiteUrls: validWebsites.map((site) => site.url),
        },
      });

    } catch (error) {
    }
  };

  return <form onSubmit={handleSubmit}></form>;
}

my inngest client looks like this:

import { Inngest } from 'inngest'

export const inngest = new Inngest({ id: 'xxxx' })

@iljapanic
Copy link

I have solved the issue by moving inngest trigger from the client component. It took me a while to realize that inngest can only be used on the server, or at least that's my current understanding. Maybe this could be more explicitly mentioned in the documentation or an error message?

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

3 participants