Reference
Pitfalls
What cost time while building and would again: npm, Next.js, Better Auth, languages, tests, Docker, renaming.
What it is about
Collected while building the template, an older project after the same
pattern and phase 1 of HenniOKF. Only what can hit the project again is
listed. The reasons in detail are in context/memory.md.
Tools
| Pitfall | What to do |
|---|---|
A fresh npm install without package-lock.json fails with "Cannot read properties of null (reading 'edgesOut')", caused by the entry overrides. | Keep the lock file and use npm ci. A new dependency with npm install <package> on the existing lock file. |
Playwright is fixed at 1.62.1, with overrides for playwright-core. | Do not raise it without installing Chromium anew. Without the override @axe-core/playwright pulls in a second core, and the build fails on two different types for Page. |
Prettier excludes Markdown, vendor/ and .data*. | After writing code run npx prettier --write <files>, otherwise npm run check fails on the line width 96. |
next dev writes a block of rules for agents into AGENTS.md at every start. | Remove the block before every commit. |
A running Next server is called next-server as a process. | Find it by its port and stop exactly that one, not with pkill -f "next start" and never with a broad pkill. |
| In a cloud session of Claude Code the preinstalled Chromium does not fit Playwright 1.62.1. | An own PLAYWRIGHT_BROWSERS_PATH with links under the expected names to the installed revision. |
Next.js
| Pitfall | What to do |
|---|---|
next build checks tests/ and e2e/ with TypeScript too. | A type error there breaks the build and with it "Check". |
| Turbopack traces file paths computed at runtime and then takes the whole project into the standalone output. | /*turbopackIgnore: true*/ in front of the computed part, as in imagePath() in lib/docs.ts and usersDir() in lib/env.ts. |
proxy.ts checks before every route. | An open address belongs into openPath() or the matcher, with tests. After a change restart the development server. |
Navigating in the browser is an RSC request with Accept: */*. | isPageRequest() counts the header rsc as a page. So it is redirected instead of answered with JSON. |
A rule in headers() overrides the header a route sets itself. Next.js sends one value per header. | A stricter route goes into STRICT_PATHS, see Recipes for extending. |
After a change to .env.local, instrumentation.ts or a new function in lib/env.ts the running server acts old. | Restart. |
A component that needs document or window while loading breaks on the server with 500, also with "use client". | Load it with dynamic(() => import(…), { ssr: false }). |
ESLint refuses JSX in a try/catch (react-hooks/error-boundaries). | Read first, then render outside, as condition() in app/status/page.tsx. |
| A page module may only have the exports Next.js knows. | Helpers belong into lib/. |
With output: "standalone" next start warns that it is not meant for it. | Without consequences. Development and browser tests use next start, the image node server.js. |
Languages
| Pitfall | What to do |
|---|---|
cookies() throws outside a request; Next.js also throws internally to switch a page to dynamic rendering. | getLocale() calls unstable_rethrow before falling back to English. Otherwise /docs freezes as static English at build time. |
cookies().set() in a server action renders the current page again. | The language switch relies on it; it needs no redirect. |
A browser test excludes a word with not.toContainText. | A new English text must not contain it. |
| A key exists in one dictionary only. | TypeScript and tests/i18n.test.ts fail; add it to both. |
Better Auth
| Pitfall | What to do |
|---|---|
| The types of the plugins get lost if the options do not stand as a literal in the call. | The options stay literally in create() in lib/users.ts. |
The plugin username refuses hyphens. | USERNAME allows only lowercase letters, digits, dot and underscore. |
| The default throttling (3 sign-ins in 10 seconds) breaks parallel browser tests. The API key plugin allows ten requests a day without a setting. | An own limit through HENNIOKF_SIGN_IN_LIMIT, /get-session without limit, keys without limit. |
allowedHosts: ["*"] makes every origin trusted. | baseURL fixed, trustedOrigins per request from host and x-forwarded-host. |
| Better Auth protects only its own routes. | Own routes call requirePermission(). |
| Passkeys are checked against the main address with port. | The browser tests set HENNIOKF_URL to their own address. |
| The messages of the library are English and technical. | The user management shows a generic message in the language of the UI. |
Tests
| Pitfall | What to do |
|---|---|
Vitest bypasses proxy.ts. | Call the proxy directly with a NextRequest, as in tests/access.test.ts. The effect is checked by e2e/access.spec.ts. |
Under NODE_ENV=test Better Auth does not check the origin. | Only the browser test "a request with a cookie from a foreign address is rejected by the library" checks it. |
browser.newContext() does not take the storageState of the project. | Intended for a session of its own. Otherwise take page or name storageState. |
Next.js keeps an element with role="alert" of its own. | Look for messages of the page in main. |
| axe requires more than colour for links in running text. | Underline them. A scrollable area needs tabIndex={0}, role="region" and aria-label. |
desktop and mobile run in parallel against the same instance. | Every test that changes data creates its own. |
On mobile the table of contents of /docs is behind a button. | Click "Show contents" first when isMobile. |
The docs tests look for a link containing "Overview" on docs/application. | No second page of that area gets "Overview" in its title. |
Without HENNIOKF_ROOT there are no accounts. | In a test use setEnv() from tests/helpers.ts and reset at the end. |
Docker
| Pitfall | What to do |
|---|---|
Without HOSTNAME=0.0.0.0 server.js listens only on the id of the container. | It stands in the Dockerfile. |
The standalone output does not copy .next/static and public/. | The Dockerfile copies them itself, plus docs/. |
docker/compose.local.yml requires LOCAL_ROOT_DIR at every call. | Export it once in the shell. |
Docker creates a missing directory of a mount as root. | Create it before and give it to UID 1000. |
Without pull_policy: always Docker takes an old latest. | It stands in docker/compose.vps.yml. |
A docker build in a cloud session does not reach Debian and npm without proxy settings. | Build in the workflow "Image". |
Renaming
| Pitfall | What to do |
|---|---|
npm run rename replaces the current name everywhere, also in running text. | A name that occurs nowhere else. HenniOKF is such a name; texts say "the template" where they mean the template. |
The script takes only files from git ls-files and the untracked ones not ignored. | A file .gitignore excludes, such as .env.local, stays old; create it anew from .env.example. |
vendor/ stays untouched. | Intended: the copies stay equal to the source. |
Back to Tests.