Skip to content

Commit 3862aac

Browse files
committed
fix(utils): restore optional logging peer deps
Bugbot flagged (and reproduction confirmed) that dropping the optional peer deps broke GCP logger init at runtime. `await import()` in utils/logging.ts resolves from utils' own module path, and pnpm's isolated linker only links a transitive dep into utils/node_modules if utils itself declares it. Without the peer, `ERR_MODULE_NOT_FOUND` is swallowed by the try/catch and services silently log without GCP structured fields. Restoring the optional peers re-links the packages into utils' node_modules when a consumer declares them directly. No API churn, both the GCP and pino-pretty regressions are addressed.
1 parent a7bf9ba commit 3862aac

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

.changeset/sdk-subpaths-utils-logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'@hyperlane-xyz/utils': patch
44
---
55

6-
Added `@hyperlane-xyz/sdk` subpath exports for `core`, `hook`, and `ism` modules, and stopped advertising service-only logging peers from the root `@hyperlane-xyz/utils` package.
6+
Added `@hyperlane-xyz/sdk` subpath exports for `core`, `hook`, and `ism` modules. Hardened `@hyperlane-xyz/utils` pretty-mode logging with a graceful fallback when `pino-pretty` is not installed.

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/utils/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@
7474
"sinon": "catalog:",
7575
"typescript": "catalog:"
7676
},
77+
"peerDependencies": {
78+
"@google-cloud/pino-logging-gcp-config": "catalog:",
79+
"pino-pretty": "catalog:"
80+
},
81+
"peerDependenciesMeta": {
82+
"@google-cloud/pino-logging-gcp-config": {
83+
"optional": true
84+
},
85+
"pino-pretty": {
86+
"optional": true
87+
}
88+
},
7789
"engines": {
7890
"node": ">=16"
7991
}

typescript/utils/src/logging.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,8 @@ export async function tryInitializeGcpLogger(options?: {
158158
if (!inKubernetes()) return null;
159159

160160
try {
161-
// Keep this import runtime-only so root utils consumers don't need the
162-
// GCP logger package present unless they actually use this code path.
163-
const gcpLoggerModule = '@google-cloud/pino-logging-gcp-config';
164161
const { createGcpLoggingPinoConfig } = await import(
165-
/* webpackIgnore: true */ gcpLoggerModule
162+
/* webpackIgnore: true */ '@google-cloud/pino-logging-gcp-config'
166163
);
167164
const serviceContext = options
168165
? {

0 commit comments

Comments
 (0)