npm package diff
Package: @forge/tunnel
Versions: 5.7.3-next.1 - 5.7.3-next.2
File: package/out/services/create-tunnel-service.js
Index: package/out/services/create-tunnel-service.js
===================================================================
--- package/out/services/create-tunnel-service.js
+++ package/out/services/create-tunnel-service.js
@@ -12,8 +12,20 @@
stopFunction;
constructor(logger) {
this.logger = logger;
}
+ handleTunnleEstablishError(e) {
+ const UNKNOWN_SYS_ERROR = 'Unknown system error -86';
+ const userSysErrors = [UNKNOWN_SYS_ERROR, 'EPERM'];
+ if (userSysErrors.some((error) => e.message.includes(error))) {
+ let errorMessage = e.message;
+ if (e.message.includes(UNKNOWN_SYS_ERROR)) {
+ errorMessage += ': Running `softwareupdate --install-rosetta` may help fix the problem';
+ }
+ throw new cli_shared_1.UserError(undefined, errorMessage);
+ }
+ throw e;
+ }
async establishTunnel({ port, id, token, tunnelUrl }) {
if (!id || !token || !tunnelUrl) {
throw new CloudflareError(undefined, 'Missing configuration to create tunnel');
}
@@ -24,24 +36,29 @@
'--protocol': 'http2'
};
options[id] = null;
process.env['TUNNEL_LOGLEVEL'] = 'debug';
- const { connections, stop, child } = (0, cloudflared_1.tunnel)(options);
- child.stdout?.on('data', (chunk) => this.logger.debug(cli_shared_1.Text.tunnel.cloudflaredLog(chunk)));
- child.stderr?.on('data', (chunk) => this.logger.debug(cli_shared_1.Text.tunnel.cloudflaredLog(chunk)));
- child.on('error', (err) => {
- this.logger.error(err);
- throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredError);
- });
- child.on('exit', (code) => {
- if (code !== 0 && code !== null) {
- throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredExit(code));
- }
- });
- await Promise.all(connections);
- this.stopFunction = stop;
- this.logger.debug(cli_shared_1.Text.tunnel.startedTunnel(tunnelUrl));
- return new url_1.URL(tunnelUrl);
+ try {
+ const { connections, stop, child } = (0, cloudflared_1.tunnel)(options);
+ child.stdout?.on('data', (chunk) => this.logger.debug(cli_shared_1.Text.tunnel.cloudflaredLog(chunk)));
+ child.stderr?.on('data', (chunk) => this.logger.debug(cli_shared_1.Text.tunnel.cloudflaredLog(chunk)));
+ child.on('error', (err) => {
+ this.logger.error(err);
+ throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredError);
+ });
+ child.on('exit', (code) => {
+ if (code !== 0 && code !== null) {
+ throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredExit(code));
+ }
+ });
+ await Promise.all(connections);
+ this.stopFunction = stop;
+ this.logger.debug(cli_shared_1.Text.tunnel.startedTunnel(tunnelUrl));
+ return new url_1.URL(tunnelUrl);
+ }
+ catch (e) {
+ throw this.handleTunnleEstablishError(e);
+ }
}
async closeTunnel() {
if (this.stopFunction) {
try {