Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pink-spoons-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cloudflared": patch
---

Remove redundant error event listeners in Tunnel class
8 changes: 7 additions & 1 deletion examples/tunnel.js
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
8 changes: 7 additions & 1 deletion examples/tunnel.mjs
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
4 changes: 0 additions & 4 deletions src/tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down
Loading