Skip to content

Instantly share code, notes, and snippets.

@imWildCat
Last active March 19, 2025 14:45
Show Gist options
  • Save imWildCat/6a91d0080cfd0b5ac6b537ae82b26d69 to your computer and use it in GitHub Desktop.
Save imWildCat/6a91d0080cfd0b5ac6b537ae82b26d69 to your computer and use it in GitHub Desktop.
nextjs 15 build error vs --no-mangling --no-lint
#39 103.1 [1] Collecting page data ...
#39 104.0 [1] TypeError: Cannot read properties of undefined (reading 'match')
#39 104.0 [1] at C (.next/server/chunks/746.js:1:4246)
#39 104.0 [1] at E (.next/server/chunks/746.js:1:4344)
#39 104.0 [1] at F (.next/server/chunks/746.js:1:4796)
#39 104.0 [1] at new rv (.next/server/chunks/746.js:7:13698)
#39 104.0 [1] at 1133 (.next/server/app/api/inngest/route.js:1:7600)
#39 104.0 [1] at t (.next/server/webpack-runtime.js:1:511)
#39 104.0 [1] at 59912 (.next/server/app/api/inngest/route.js:77:10748)
#39 104.0 [1] at t (.next/server/webpack-runtime.js:1:511)
#39 104.0 [1] at <unknown> (.next/server/app/api/inngest/route.js:78:25657)
#39 104.0 [1] at t.a (.next/server/webpack-runtime.js:1:1292)
#39 104.0 [1]
#39 104.0 [1] > Build error occurred
#39 104.0 [1] [Error: Failed to collect page data for /api/inngest] { type: 'Error' }
#39 104.1 [1]  ELIFECYCLE  Command failed with exit code 1.
#39 104.1 [1] cd apps/backend && pnpm build exited with code 1
// azure-email.ts
import { EmailClient } from "@azure/communication-email";
import { env } from "~/env";
// I spent ~24 hours before finding the problem is from this code below
export const azureEmailClient = new EmailClient(env.AZURE_COMMUNICATION_SERVICES_CONNECTION_STRING);
// in build env (docker), `AZURE_COMMUNICATION_SERVICES_CONNECTION_STRING` is not set.
// because the error message points to inngest not this code
// see error-build.log
// this works because it constructs the Email Client when this function is called
export function getAzureEmailClient() {
return new EmailClient(env.AZURE_COMMUNICATION_SERVICES_CONNECTION_STRING);
}
@imWildCat
Copy link
Author

if using npx next build --no-mangling --no-lint
the error stack looks right.

   Creating an optimized production build ...
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (246kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
 ✓ Compiled successfully
 ✓ Checking validity of types    
   Collecting page data  .TypeError: Cannot read properties of undefined (reading 'match')
    at tryParseConnectionString (.next/server/chunks/4940.js:4:29038)
    at parseConnectionString (.next/server/chunks/4940.js:4:29251)
    at parseClientArguments (.next/server/chunks/4940.js:4:30159)
    at new EmailClient (.next/server/chunks/4940.js:10:18780)
    at 33580 (.next/server/app/api/inngest/route.js:77:66599)
    at __webpack_require__ (.next/server/webpack-runtime.js:1:712)
    at 11433 (.next/server/app/api/inngest/route.js:71:4459)
    at __webpack_require__ (.next/server/webpack-runtime.js:1:712)
    at <unknown> (.next/server/app/api/inngest/route.js:1:1713)
    at __webpack_require__.a (.next/server/webpack-runtime.js:1:2128)

> Build error occurred
[Error: Failed to collect page data for /api/inngest] { type: 'Error' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment