fix(identity): copy loadAudiusSdk.cjs into build output#14474
Conversation
The production container runs the compiled entrypoint at build/src/index.js, which requires '../loadAudiusSdk.cjs' relative to __dirname (resolving to build/loadAudiusSdk.cjs). Because loadAudiusSdk.cjs lives outside src/ as a plain .cjs file, tsc never emits it into build/, and the copyfiles step only copied src/emails. This caused MODULE_NOT_FOUND at startup in prod. Copy loadAudiusSdk.cjs into build/ during the build so the relative require resolves in both dev (ts-node-dev) and prod (compiled).
|
|
Dependency limit exceeded — report not shown. This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report. Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard. Socket is always free for open source. If this is a non-commercial open source project, contact us to request a free Team account. |
src/utils/disposableEmail.js reads src/data/disposable_email_blocklist.conf at runtime via fs.readFileSync. tsc does not emit .conf files, and the copyfiles step only copied src/emails, so build/src/data/ was missing in the production image. This is a latent ENOENT (the blocklist loads lazily on the first disposable-email check during signup) from the same email verification PR as the loadAudiusSdk.cjs issue. Copy src/data into build/src so the blocklist resolves in prod.
Problem
The identity-service pod crashes on startup with:
Root cause
The production container runs the compiled entrypoint
node build/src/index.js(scripts/start.sh). That file requires the SDK loader via a path relative to__dirname:The
..resolves differently depending on where the entrypoint physically lives:ts-node-devrunssrc/index.ts):__dirname=identity-service/src→ resolves to package-rootloadAudiusSdk.cjs✓noderunsbuild/src/index.js):__dirname=identity-service/build/src→ resolves tobuild/loadAudiusSdk.cjs✗loadAudiusSdk.cjsdeliberately lives outsidesrc/as a plain.cjsfile (sots-node-devdoesn't transpile itsimport()intorequire()and triggerERR_REQUIRE_ESM). Because it isn't a.tsfile,tscnever emits it intobuild/, and thecopyfilesbuild step only copiedsrc/emails. Sobuild/loadAudiusSdk.cjswas never present in the production image →MODULE_NOT_FOUND.Fix
Extend the
copyfilesscript to also copyloadAudiusSdk.cjsintobuild/, so the existing relativerequire('../loadAudiusSdk.cjs')resolves correctly in both dev and prod.Verification
copyfileslocally and confirmedbuild/loadAudiusSdk.cjsis produced.loadAudiusSdk(a function).https://claude.ai/code/session_011oMzUJoMTNRaGUh7qPt1jp
Generated by Claude Code