Skip to content

fix: deduplicate nested pino in global paperclipai install - #1355

Merged
shunkakinoki merged 2 commits into
mainfrom
fix/dedupe-nested-pino
Apr 5, 2026
Merged

fix: deduplicate nested pino in global paperclipai install#1355
shunkakinoki merged 2 commits into
mainfrom
fix/dedupe-nested-pino

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Summary

After bun install --global, remove the nested pino from @paperclipai/server/node_modules/ so there's only one copy.

Root cause

@paperclipai/server gets its own nested pino@9.14.0, while pino-http@10.5 imports stringifySym from the top-level pino@9.14.0. Same version, but different module instances = different Symbol references. The logger created by the nested pino doesn't have the top-level pino's Symbol, so logger[stringifySym] is undefined → crash.

Fix

Delete ~/.bun/install/global/node_modules/@paperclipai/server/node_modules/pino after install so everything resolves to one pino instance.

Tested

10/10 requests returned 200 after deduplication.


Summary by cubic

Deduplicates all overridden packages in global installs by removing nested copies under node_modules after bun install --global, ensuring a single version (e.g., pino). Prevents pino-http stringifySym crashes and similar symbol conflicts; 10/10 requests now return 200.

Written for commit 116329b. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 5, 2026 01:32
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 5, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d07c7851-d9e2-4099-b78b-d9184158a708

📥 Commits

Reviewing files that changed from the base of the PR and between 8319a74 and 116329b.

📒 Files selected for processing (2)
  • home-manager/modules/npm-globals/install-npm-globals.sh
  • spec/npm_globals_spec.sh

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added automatic deduplication of nested package copies during npm globals installation, resolving conflicts by maintaining a single top-level version of overridden packages.
  • Tests

    • Added verification tests for the deduplication functionality.

Walkthrough

The changes add a post-install cleanup step to the npm-globals installation script that reads package.json overrides and removes nested occurrences of overridden packages from Bun's global node_modules directory. Corresponding test assertions verify this deduplication behavior.

Changes

Cohort / File(s) Summary
Post-install Deduplication
home-manager/modules/npm-globals/install-npm-globals.sh
Added cleanup logic that extracts override keys from package.json, searches for nested package instances via find command, and removes nested duplicates while logging deduplication messages.
Test Coverage
spec/npm_globals_spec.sh
Added test assertions to verify "Deduplicated nested" output messages and validate find command operations against GLOBAL_MODULES and node_modules paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through node_modules deep,
Finding nested copies that shouldn't sleep—
With override keys in hand, so keen,
Tidying packages, keeping things clean!
One package rules them all, no more dupes in sight!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dedupe-nested-pino

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 and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 5, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Deduplicated pino in global installs by removing the nested copy under @paperclipai/server after bun install --global, ensuring a single pino instance. Fixes a pino-http stringifySym mismatch that caused crashes; 10/10 requests now return 200.

What changed?

  • home-manager/modules/npm-globals/install-npm-globals.sh: The script now includes a step to deduplicate the 'pino' dependency within the '@paperclipai/server' package to prevent 'Symbol' mismatch errors, ensuring 'pino-http' and '@paperclipai/server' use the same 'pino' instance.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a deduplication step in the install-npm-globals.sh script to remove a nested pino directory within @paperclipai/server, which prevents crashes caused by Symbol mismatches. The review feedback recommends using rm -rf combined with || true for the deletion to ensure the script is robust and consistent with existing error handling patterns.

# loggers with its own nested copy — different Symbol instances cause a crash.
NESTED_PINO="${HOME}/.bun/install/global/node_modules/@paperclipai/server/node_modules/pino"
if [ -d "$NESTED_PINO" ]; then
rm -r "$NESTED_PINO"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To ensure the script is robust and consistent with the error handling patterns used elsewhere in this file (e.g., lines 41, 49, 60), consider using rm -rf and appending || true. This prevents the script from exiting prematurely if the deletion fails—which is a non-critical cleanup step—and avoids potential interactive prompts if files are write-protected.

Suggested change
rm -r "$NESTED_PINO"
rm -rf "$NESTED_PINO" || true
References
  1. Maintain consistency with established patterns for writing scripts that are extracted from Nix expressions.

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

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a post-install cleanup step to Bun’s global npm package installation script to remove a duplicated nested pino dependency under @paperclipai/server, avoiding runtime crashes caused by Symbol mismatches between two module instances.

Changes:

  • Add a deduplication step that deletes @paperclipai/server/node_modules/pino after bun install --global.
  • Document the root cause (Symbol mismatch between nested and top-level pino) inline in the script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +71
rm -r "$NESTED_PINO"
echo "Removed nested pino from @paperclipai/server (deduplicated)"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

rm -r runs under set -e and will abort the whole install if removal fails (permissions, transient FS issues, etc.). Consider using a non-interactive forced remove (rm -rf -- ...) and only printing the "Removed" message when the command succeeds (or emit a warning but keep the script succeeding).

Suggested change
rm -r "$NESTED_PINO"
echo "Removed nested pino from @paperclipai/server (deduplicated)"
if rm -rf -- "$NESTED_PINO"; then
echo "Removed nested pino from @paperclipai/server (deduplicated)"
else
echo "Warning: failed to remove nested pino from @paperclipai/server" >&2
fi

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +70
NESTED_PINO="${HOME}/.bun/install/global/node_modules/@paperclipai/server/node_modules/pino"
if [ -d "$NESTED_PINO" ]; then
rm -r "$NESTED_PINO"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

This hardcodes Bun’s global install path to ~/.bun/install/global/.... If the user has Bun installed in a non-default location (e.g., via BUN_INSTALL or similar), this cleanup won’t run and the crash may persist. Consider deriving the global root via Bun itself (e.g., a bun pm -g query) or reusing a single computed global dir variable used by both GLOBAL_PKG and this path.

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +71
rm -r "$NESTED_PINO"
echo "Removed nested pino from @paperclipai/server (deduplicated)"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

There’s ShellSpec coverage for this script (spec/npm_globals_spec.sh), but it currently won’t catch regressions to this new deduplication step. Please add/extend a spec assertion to verify the nested pino path cleanup logic is present (and ideally that it’s guarded and non-fatal).

Suggested change
rm -r "$NESTED_PINO"
echo "Removed nested pino from @paperclipai/server (deduplicated)"
if rm -r "$NESTED_PINO"; then
echo "Removed nested pino from @paperclipai/server (deduplicated)"
else
echo "Warning: failed to remove nested pino from @paperclipai/server; continuing" >&2
fi

Copilot uses AI. Check for mistakes.
@shunkakinoki
shunkakinoki merged commit 58f5672 into main Apr 5, 2026
29 of 31 checks passed
@shunkakinoki
shunkakinoki deleted the fix/dedupe-nested-pino branch April 5, 2026 04:33
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.

2 participants