Skip to content

fix(docker): ship packages/shared's nested node_modules to runtime - #1875

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
fix/ship-shared-nested-deps
Jul 26, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
fix/ship-shared-nested-deps

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Jul 26, 2026 •

Copy link
Copy Markdown
Owner

Symptom

lucky-staging-backend is crash-looping on the host:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'axios'
  imported from /app/packages/shared/dist/services/LyricsService.js

Production is unaffected only because it predates the cause. It runs 597f2cf (v2.36.1, 2026-07-16); the next production deploy from main would break identically.

Root cause

npm nests a dependency under packages/shared/node_modules instead of hoisting it when another workspace pins a conflicting range. packages/frontend also depends on axios, so the lockfile now resolves:

packages/frontend/node_modules/axios  1.18.1
packages/shared/node_modules/axios    1.18.1

with no node_modules/axios at the root. That changed in 10b4a8cb (#1869, npm audit remediation), which rewrote package-lock.json.

deps-production already copies that directory (Dockerfile L122) and prunes devDeps from it, but production-bot and production-backend never forwarded it. They copy root node_modules, packages/<app>/node_modules and packages/shared/dist, so shared/dist imported packages the image did not contain.

Evidence

image node_modules/axios packages/shared/node_modules state
lucky-backend:597f2cf (prod) present, 1.16.1 absent healthy 4d
lucky-backend:staging-8011a29 absent absent crash loop

Fix

Forward packages/shared/node_modules into both runtime stages, mirroring the existing packages/<app>/node_modules copies.

Copies the whole directory rather than naming axios, because zod is nested there too and is also a runtime dependency of shared, so it was the next crash waiting. Nested entries under packages/shared:

prod deps:  axios, zod          <- both needed at runtime
devDeps:    @swc/cli, typescript, glob, lru-cache,
            path-scurry, balanced-match, brace-expansion

The devDeps are already stripped by the npm prune --omit=dev in deps-production, so this adds no image bloat.

Why not force hoisting instead

Adding axios to the root manifest or running npm dedupe would treat the symptom and stay fragile: any future range conflict in any workspace re-nests a dependency and breaks runtime again, silently, at container start. Copying the directory is deterministic and symmetric with what the bot and backend packages already get.

Verification

Pending CI: once the image builds, confirm /app/node_modules/axios or /app/packages/shared/node_modules/axios resolves in production-backend, then that staging comes up healthy rather than restarting.


Summary by cubic

Ship packages/shared/node_modules into both bot and backend runtime images to fix staging crashes from missing nested deps (axios, zod) imported by packages/shared/dist.

  • Bug Fixes
    • Copy packages/shared/node_modules from deps-production into production-bot and production-backend stages.
    • Handles npm’s nested deps when workspace ranges conflict, preventing ERR_MODULE_NOT_FOUND.
    • Directory is already dev-pruned; no image bloat.

Written for commit b5712ab. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@LucasSantana-Dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 70d6dadd-6b23-43ae-b0b0-2c336e0a9f75

📥 Commits

Reviewing files that changed from the base of the PR and between 199d91d and b5712ab.

📒 Files selected for processing (1)
  • Dockerfile
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ship-shared-nested-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Jul 26, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Auto-approved: Fixes crash-loop by copying nested shared/node_modules into runtime images, mirroring existing app node_modules copies. Bounded, deterministic fix for a missing directory causing ERR_MODULE_NOT_FOUND.

Re-trigger cubic

lucky-staging-backend is crash-looping:

  Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'axios'
    imported from /app/packages/shared/dist/services/LyricsService.js

npm nests a dependency under packages/shared/node_modules instead of
hoisting it when another workspace pins a conflicting range. packages/
frontend also depends on axios, so the lock now places axios@1.18.1 at
packages/shared/node_modules/axios rather than node_modules/axios. This
started with #1869 (npm audit remediation), which rewrote the lock.

deps-production already copies that directory (L122) and prunes devDeps,
but production-bot and production-backend never forwarded it, so
shared/dist imported packages the image did not contain.

Copies the whole directory rather than naming axios: zod is nested there
too and is also a runtime dep of shared, so it was the next crash. The
rest nested there are devDeps and are already pruned.

Verified on the images: prod 597f2cf (pre-#1869) has node_modules/axios
at 1.16.1 and is healthy; staging-8011a29 has neither
node_modules/axios nor packages/shared/node_modules.
@LucasSantana-Dev
LucasSantana-Dev force-pushed the fix/ship-shared-nested-deps branch from 96d089a to b5712ab Compare July 26, 2026 22:00
@github-actions github-actions Bot added size/s and removed dependencies Pull requests that update a dependency file size/m labels Jul 26, 2026
@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 6516ad2 into main Jul 26, 2026
42 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/ship-shared-nested-deps branch July 26, 2026 22:04
LucasSantana-Dev added a commit that referenced this pull request Jul 26, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>2.37.2</summary>

##
[2.37.2](v2.37.1...v2.37.2)
(2026-07-26)


### Bug Fixes

* **docker:** ship packages/shared's nested node_modules to runtime
([#1875](#1875))
([6516ad2](6516ad2))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Release 2.37.2 fixes the Docker image to include `packages/shared`’s
nested `node_modules`. This prevents missing dependency errors when
running in production.

<sup>Written for commit 5d996bc.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/LucasSantana-Dev/Lucky/pull/1891?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->
This was referenced Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant