From 454e97ff1cb08a00ba8409c143be0e52f3e56a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Aaron?= Date: Tue, 7 Apr 2026 23:27:39 +0200 Subject: [PATCH] fix: change console.info to console.debug to keep stdout clean console.info writes to stdout, which pollutes output for agents and tools consuming the SDK. console.debug writes to stderr instead. Also update eslint no-console rule to disallow console.info going forward. Co-Authored-By: Claude Opus 4.6 (1M context) --- .eslintrc.json | 2 +- src/nwc/NWAClient.ts | 4 ++-- src/nwc/NWCClient.ts | 13 ++++++------- src/nwc/NWCWalletService.ts | 12 ++++++------ src/webln/OauthWeblnProvider.ts | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d67de6f0..4767f2bf 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,7 +21,7 @@ } ], "@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }], - "no-console": ["error", { "allow": ["info", "warn", "error"] }], + "no-console": ["error", { "allow": ["debug", "warn", "error"] }], "no-constant-binary-expression": "error" }, "globals": { diff --git a/src/nwc/NWAClient.ts b/src/nwc/NWAClient.ts index 72301c59..7323ab9e 100644 --- a/src/nwc/NWAClient.ts +++ b/src/nwc/NWAClient.ts @@ -215,12 +215,12 @@ export class NWAClient { onclose: (reasons) => { // NOTE: this fires when all relays were closed once. There is no reconnect logic in nostr-tools // See https://github.com/nbd-wtf/nostr-tools/issues/513 - console.info("relay connection closed", reasons); + console.debug("relay connection closed", reasons); endPromise?.(); }, }, ); - console.info("subscribed to relays"); + console.debug("subscribed to relays"); await new Promise((resolve) => { endPromise = () => { diff --git a/src/nwc/NWCClient.ts b/src/nwc/NWCClient.ts index cc171ffa..d9c3e073 100644 --- a/src/nwc/NWCClient.ts +++ b/src/nwc/NWCClient.ts @@ -122,8 +122,7 @@ export class NWCClient { } as NWCOptions; this.relayUrls = this.options.relayUrls; - this.pool = new SimplePool({ - }); + this.pool = new SimplePool({}); if (this.options.secret) { this.secret = ( this.options.secret.toLowerCase().startsWith("nsec") @@ -718,7 +717,7 @@ export class NWCClient { try { await this._checkConnected(); await this._selectEncryptionType(); - console.info("subscribing to relays"); + console.debug("subscribing to relays"); sub = this.pool.subscribe( this.relayUrls, { @@ -765,12 +764,12 @@ export class NWCClient { onclose: (reasons) => { // NOTE: this fires when all relays were closed once. There is no reconnect logic in nostr-tools // See https://github.com/nbd-wtf/nostr-tools/issues/513 - console.info("relay connection closed", reasons); + console.debug("relay connection closed", reasons); endPromise?.(); }, }, ); - console.info("subscribed to relays"); + console.debug("subscribed to relays"); await new Promise((resolve) => { endPromise = () => { @@ -865,7 +864,7 @@ export class NWCClient { return; } if (response.result) { - // console.info("NIP-47 result", response.result); + // console.debug("NIP-47 result", response.result); if (resultValidator(response.result)) { resolve(response.result); } else { @@ -1009,7 +1008,7 @@ export class NWCClient { ); } if (response.result) { - // console.info("NIP-47 result", response.result); + // console.debug("NIP-47 result", response.result); if (!resultValidator(response.result)) { clearTimeout(replyTimeoutCheck); sub.close(); diff --git a/src/nwc/NWCWalletService.ts b/src/nwc/NWCWalletService.ts index cbdf3264..23f13d4d 100644 --- a/src/nwc/NWCWalletService.ts +++ b/src/nwc/NWCWalletService.ts @@ -102,9 +102,9 @@ export class NWCWalletService { (async () => { while (subscribed) { try { - console.info("checking connection to relay"); + console.debug("checking connection to relay"); await this._checkConnected(); - console.info("subscribing to relay"); + console.debug("subscribing to relay"); sub = this.relay.subscribe( [ { @@ -115,11 +115,11 @@ export class NWCWalletService { ], {}, ); - console.info("subscribed to relays"); + console.debug("subscribed to relays"); sub.onevent = async (event) => { try { - // console.info("Got event", event); + // console.debug("Got event", event); const encryptionType = (event.tags.find( (t) => t[0] === "encryption", )?.[1] || "nip04") as Nip47EncryptionType; @@ -271,7 +271,7 @@ export class NWCWalletService { encryptionType: Nip47EncryptionType, ) { let encrypted; - // console.info("encrypting with" + encryptionType); + // console.debug("encrypting with" + encryptionType); if (encryptionType === "nip04") { encrypted = await nip04.encrypt( keypair.walletSecret, @@ -294,7 +294,7 @@ export class NWCWalletService { encryptionType: Nip47EncryptionType, ) { let decrypted; - // console.info("decrypting with" + encryptionType); + // console.debug("decrypting with" + encryptionType); if (encryptionType === "nip04") { decrypted = await nip04.decrypt( keypair.walletSecret, diff --git a/src/webln/OauthWeblnProvider.ts b/src/webln/OauthWeblnProvider.ts index b2b31977..8ee9af50 100644 --- a/src/webln/OauthWeblnProvider.ts +++ b/src/webln/OauthWeblnProvider.ts @@ -149,7 +149,7 @@ export class OauthWeblnProvider { !processingCode ) { processingCode = true; // make sure we request the access token only once - console.info("Processing OAuth code response"); + console.debug("Processing OAuth code response"); const code = data.payload.code; try { await this.auth.requestAccessToken(code);