Skip to content

fix(next-mdx): forward plugin load errors to webpack callback#94119

Open
Jinoko01 wants to merge 1 commit into
vercel:canaryfrom
Jinoko01:fix/next-mdx-unhandled-promise-rejection
Open

fix(next-mdx): forward plugin load errors to webpack callback#94119
Jinoko01 wants to merge 1 commit into
vercel:canaryfrom
Jinoko01:fix/next-mdx-unhandled-promise-rejection

Conversation

@Jinoko01
Copy link
Copy Markdown

@Jinoko01 Jinoko01 commented May 26, 2026

What?

Add .catch() handler to the Promise in mdx-js-loader.js so that
plugin resolution failures are properly forwarded to webpack's error callback.

Why?

When a plugin string path fails to resolve (e.g. typo in plugin name,
missing package), getOptions() returns a rejected Promise. Without
.catch(), webpack's callback is never called, causing the build to
hang indefinitely or throw an unhandled promise rejection instead of
a clear error message.

How?

Chain .catch((error) => callback(error)) after the existing .then()
in nextMdxLoader.

Fixes #94118

Copy link
Copy Markdown
Contributor

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for the changes. You can use pnpm new-test (or ask an AI agent)

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

Successfully merging this pull request may close these issues.

@next/mdx: unhandled promise rejection when plugin path fails to resolve in mdx-js-loader

2 participants