Skip to content

fix(api): stop the intermittent nestjs async-module require failure in tests - #1384

Merged
dennisofficial merged 1 commit into
mainfrom
dennis/nestjs-async-flake
Oct 23, 2026
Merged

dennisofficial merged 1 commit into
mainfrom
dennis/nestjs-async-flake

Conversation

@dennisofficial

Copy link
Copy Markdown
Owner

Decision #98. apps/api specs intermittently failed with require() async module "@nestjs/core" is unsupported while @nestjs/throttler loaded (reruns on #1366, #1373, #1378).

Root cause: a Bun module-loader race, oven-sh/bun#33180 (regressed in 1.3.14; the fix, oven-sh/bun#37185, is still open). @nestjs/throttler is CJS and require()s @nestjs/common/@nestjs/core from its module body while the ESM graph is still fetching them. A require() that lands on an entry with Fetching status is misreported as an async module. Ruled out:

  • top-level await: none anywhere in the installed @nestjs/* graph;
  • the incremental preload: the failure reproduces without it;
  • plain bun importing the same graph: clean, 0/60.

Fix: apps/api/nestjs-preload.ts, loaded first in bunfig.toml, imports both packages before any spec loads, so throttler's require() takes the synchronous path.

Configuration Before After
single spec (sandbox-checkpoint-write) 3/30 0/40
two specs together 1/12 0/40
BUN_TEST_INCREMENTAL=1 — 0/40
full apps/api suite intermittent (main run 39888923913) 0 async-module errors, 1197 tests

Test-only: nothing in the shipped app changes.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
atlas-api Ready Ready Preview Oct 23, 2026 4:18am UTC
2 Skipped Deployments
Project Deployment Actions Updated
atlas Skipped Skipped Oct 23, 2026 4:18am UTC
atlas-storybook Skipped Skipped Oct 23, 2026 4:18am UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – atlas October 23, 2026 04:18 Inactive
@dennisofficial
dennisofficial marked this pull request as ready for review October 23, 2026 04:19
@dennisofficial
dennisofficial merged commit cd51335 into main Oct 23, 2026
9 checks passed

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – atlas-api — 1359eef5 Deployed Oct 23, 2026 by vercel[bot]
Preview – atlas — 1359eef5 Deployed Oct 23, 2026 by vercel[bot]
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.

1 participant