AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

@Next/Mdx: Unhandled Promise Rejection When Plugin Path Fails To Resolve In Mdx-Js-Loader

In @next/mdx, the mdx-js-loader uses getOptions() which returns a Promise. The Promise lacks a .catch(), so if a plugin path fails to resolve (e.g. missing module, ESM import failure), the rejection is unhandled. This causes webpack's build to hang without a clear error, instead of forwarding the error to webpack's callback.

highConfidence 95%Next.jsServer ActionsApp Routernext buildAffected V16.3.0-Canary.29

Origin Analysis

The Promise returned by getOptions() in packages/next-mdx/mdx-js-loader.js is missing a .catch() handler, so rejected promises are never passed to webpack's callback, leading to an unhandled promise rejection and build stall.
1. Clone https://github.com/Jinoko01/mdx-catch-bug 2. Run npm install 3. Run npm run build (next build --webpack) 4. Observe build hangs indefinitely or throws UnhandledPromiseRejection 'Cannot find module ...'

Fixing Code Block

Edge Case Audit

Ensure the callback error path does not conflict with mdxLoader's own callback if it also handles errors; verify the loader's callback is not called twice. Rollback: simply remove the added .catch() if unexpected double-callback or error swallowing occurs.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state