From 86bdc8433924c0eeb9565a06a64a0a0533c98484 Mon Sep 17 00:00:00 2001 From: JacobLinCool Date: Fri, 1 Aug 2025 21:41:02 +0800 Subject: [PATCH 1/3] fix: remove redundant error event listeners in Tunnel class --- src/tunnel.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tunnel.ts b/src/tunnel.ts index c74cb7d..f6113db 100644 --- a/src/tunnel.ts +++ b/src/tunnel.ts @@ -76,14 +76,10 @@ export class Tunnel extends EventEmitter { // cloudflared outputs to stderr, but I think its better to listen to stdout too this.on("stdout", (output) => { this.processOutput(output); - }).on("error", (err) => { - this.emit("error", err); }); this.on("stderr", (output) => { this.processOutput(output); - }).on("error", (err) => { - this.emit("error", err); }); } From 779c35b22f32addabb237537e02e94c82273db88 Mon Sep 17 00:00:00 2001 From: JacobLinCool Date: Fri, 1 Aug 2025 21:43:46 +0800 Subject: [PATCH 2/3] chore: add changeset --- .changeset/pink-spoons-smash.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pink-spoons-smash.md diff --git a/.changeset/pink-spoons-smash.md b/.changeset/pink-spoons-smash.md new file mode 100644 index 0000000..ef5d110 --- /dev/null +++ b/.changeset/pink-spoons-smash.md @@ -0,0 +1,5 @@ +--- +"cloudflared": patch +--- + +Remove redundant error event listeners in Tunnel class From 0f675173a2b7f0a6f84def9227eafce735eb2bcc Mon Sep 17 00:00:00 2001 From: JacobLinCool Date: Fri, 1 Aug 2025 21:51:16 +0800 Subject: [PATCH 3/3] docs: update tunnel example code to check for and install cloudflared binary if missing --- examples/tunnel.js | 8 +++++++- examples/tunnel.mjs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/tunnel.js b/examples/tunnel.js index cf912be..45845af 100644 --- a/examples/tunnel.js +++ b/examples/tunnel.js @@ -1,9 +1,15 @@ -const { Tunnel } = require("cloudflared"); +const fs = require("node:fs"); +const { Tunnel, bin, install } = require("cloudflared"); console.log("Cloudflared Tunnel Example."); main(); async function main() { + if (!fs.existsSync(bin)) { + // install cloudflared binary + await install(bin); + } + // run: cloudflared tunnel --hello-world const tunnel = Tunnel.quick(); diff --git a/examples/tunnel.mjs b/examples/tunnel.mjs index c8d8cc9..e666335 100644 --- a/examples/tunnel.mjs +++ b/examples/tunnel.mjs @@ -1,9 +1,15 @@ -import { Tunnel } from "cloudflared"; +import fs from "node:fs"; +import { Tunnel, bin, install } from "cloudflared"; console.log("Cloudflared Tunnel Example."); main(); async function main() { + if (!fs.existsSync(bin)) { + // install cloudflared binary + await install(bin) + } + // run: cloudflared tunnel --hello-world const tunnel = Tunnel.quick();