Files
danandGitHub 4ebf4bd6aa Only track pending imports for real promises (#95789)
Extracted from https://github.com/vercel/next.js/pull/95468.

Fixes a module with `then` export hanging the module tracking during the
build.

---

`trackPendingImport` needs to track actually async modules (top-level
await).

Before this change, this codepath was happy to adopt any thenable. But
since thenables may not be Promises, this could break things downstream,
hence why we had `Promise.resolve` there.

However, we don't *want* to adopt arbitrary thenables here. **Tracking
is for top-level awaited modules.** For example, `module.exports = new
Promise(() => {})` has a `.then` but we don't want to track that. It's
not TLA.

This is why, to catch real top-level await modules, we narrow the check
to `instanceof Promise`.

We add tests for:

- A client module with a `then` function export (**hangs** on Turbopack
before this PR with CC on)
- Exporting a literal Promise (works before and after, but worth testing
for future regressions)
2026-07-15 10:49:05 +01:00

9 lines
122 B
JavaScript

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
cacheComponents: true,
}
module.exports = nextConfig