Skip to content

Commit 4b76aa2

Browse files
authored
Merge pull request #35 from JacobLinCool/fix-error-handling
fix: remove redundant error event listeners in Tunnel class
2 parents 0b895ea + 0f67517 commit 4b76aa2

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.changeset/pink-spoons-smash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cloudflared": patch
3+
---
4+
5+
Remove redundant error event listeners in Tunnel class

examples/tunnel.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
const { Tunnel } = require("cloudflared");
1+
const fs = require("node:fs");
2+
const { Tunnel, bin, install } = require("cloudflared");
23

34
console.log("Cloudflared Tunnel Example.");
45
main();
56

67
async function main() {
8+
if (!fs.existsSync(bin)) {
9+
// install cloudflared binary
10+
await install(bin);
11+
}
12+
713
// run: cloudflared tunnel --hello-world
814
const tunnel = Tunnel.quick();
915

examples/tunnel.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { Tunnel } from "cloudflared";
1+
import fs from "node:fs";
2+
import { Tunnel, bin, install } from "cloudflared";
23

34
console.log("Cloudflared Tunnel Example.");
45
main();
56

67
async function main() {
8+
if (!fs.existsSync(bin)) {
9+
// install cloudflared binary
10+
await install(bin)
11+
}
12+
713
// run: cloudflared tunnel --hello-world
814
const tunnel = Tunnel.quick();
915

src/tunnel.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,10 @@ export class Tunnel extends EventEmitter {
7676
// cloudflared outputs to stderr, but I think its better to listen to stdout too
7777
this.on("stdout", (output) => {
7878
this.processOutput(output);
79-
}).on("error", (err) => {
80-
this.emit("error", err);
8179
});
8280

8381
this.on("stderr", (output) => {
8482
this.processOutput(output);
85-
}).on("error", (err) => {
86-
this.emit("error", err);
8783
});
8884
}
8985

0 commit comments

Comments
 (0)