Skip to content

Conversation

Copy link

Copilot AI commented Aug 19, 2025

Fixes #10

Problem

The library was failing when pino-pretty was not available with the error:

Error: unable to determine transport target for "pino-pretty"

This occurred because the logger configuration in src/logger.ts was hardcoded to use pino-pretty as a transport in non-production environments, but pino-pretty was only listed as a devDependency. This meant:

  • Users installing the package wouldn't get pino-pretty by default
  • Production deployments without dev dependencies would fail if NODE_ENV wasn't set to "production"
  • The library would crash at initialization instead of gracefully degrading

Solution

Modified the logger configuration to gracefully handle when pino-pretty is not available:

  • Added a getTransportConfig() helper function that uses require.resolve() to check if pino-pretty is available
  • Falls back to the default pino transport (JSON logging) when pino-pretty is not found
  • Maintains existing behavior:
    • Pretty logging in development when pino-pretty is available
    • No transport override in production environments
    • Same log levels and configuration

Testing

Verified the fix works in all scenarios:

Without pino-pretty:

// Works correctly with JSON logging
{"level":40,"time":1755633252091,"pid":3754,"hostname":"...","name":"rivalsjs","msg":"..."}

With pino-pretty:

// Works correctly with pretty formatting
[19:53:00.409] WARN (rivalsjs/3634): `retryOnRateLimit` is not set...

This ensures the library works reliably regardless of whether users have pino-pretty installed, while still providing a better development experience when it's available.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 19, 2025 19:51
Co-authored-by: MatthewSH <3768988+MatthewSH@users.noreply.github.com>
Co-authored-by: MatthewSH <3768988+MatthewSH@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix the issue outlined in @MatthewSH/rivalsjs/issues/10 Fix pino-pretty dependency issue with graceful fallback Aug 19, 2025
Copilot AI requested a review from MatthewSH August 19, 2025 19:55
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.

Requires pino pretty

2 participants