Skip to content

CloudflareTunnelClient crashes on undefined URL even when CLOUDFLARE_TOKEN is not set #1035

@chadrwalters

Description

@chadrwalters

Problem

CloudflareTunnelClient.js line 39 crashes with:

Cannot read properties of undefined (reading 'startsWith')

The code:

tunnel.on("url", (url) => {
    if (!url.startsWith("http")) {  // url is undefined
        url = `https://${url}`;
    }

This produces hundreds of identical error log lines during startup:

[ERROR] [CLI] Failed to start edge application: Cannot read properties of undefined (reading 'startsWith')

Context

  • CLOUDFLARE_TOKEN is not set in the environment
  • The SharedApplicationServer has a guard (if (!this.skipTunnel && process.env.CLOUDFLARE_TOKEN)) that should prevent tunnel startup
  • Despite this, the error fires repeatedly during startup before Cyrus stabilizes
  • Cyrus eventually starts successfully (0 restarts, stable uptime) but the error log is polluted

Expected Behavior

  1. The url callback should guard against undefined: if (url && !url.startsWith("http"))
  2. Or the tunnel client should never be instantiated when CLOUDFLARE_TOKEN is absent

Environment

  • Cyrus v0.2.37
  • Self-hosted on Mac Mini (Apple Silicon)
  • No CLOUDFLARE_TOKEN configured

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions