wavetermdev/waveterm · error
error generating random string: %w
Error message
error generating random string: %w
What it means
The listener derives a random socket name from 16 random bytes via utilfn.RandomHexString. If the platform CSPRNG fails, the error is wrapped as 'error generating random string'. This is extremely rare and almost always indicates an OS-level entropy/crypto failure.
Source
Thrown at pkg/remote/conncontroller/conncontroller.go:281
}
func (conn *SSHConn) GetName() string {
// no lock required because opts is immutable
return conn.Opts.String()
}
func (conn *SSHConn) OpenDomainSocketListener(ctx context.Context) error {
conn.Infof(ctx, "running OpenDomainSocketListener...\n")
allowed := WithLockRtn(conn, func() bool {
return conn.Status == Status_Connecting
})
if !allowed {
return fmt.Errorf("cannot open domain socket for %q when status is %q", conn.GetName(), conn.GetStatus())
}
client := conn.GetClient()
randStr, err := utilfn.RandomHexString(16) // 64-bits of randomness
if err != nil {
return fmt.Errorf("error generating random string: %w", err)
}
sockName := fmt.Sprintf("/tmp/waveterm-%s.sock", randStr)
conn.Infof(ctx, "generated domain socket name %s\n", sockName)
listener, err := client.ListenUnix(sockName)
if err != nil {
return fmt.Errorf("unable to request connection domain socket: %v", err)
}
conn.WithLock(func() {
conn.DomainSockName = sockName
conn.DomainSockListener = listener
})
conn.Infof(ctx, "successfully connected domain socket\n")
go func() {
defer func() {
panichandler.PanicHandler("conncontroller:OpenDomainSocketListener", recover())
}()
defer conn.WithLock(func() {
conn.DomainSockListener = nilView on GitHub (pinned to a4447c1563)
Solutions
- Inspect the wrapped underlying error to identify the OS-level RNG failure
- Check that /dev/urandom (or the platform equivalent) is readable in the environment
- Retry after fixing the environment; the failure is transient in virtually all cases
Defensive patterns
Strategy: retry
Try / catch
err := conn.OpenDomainSocketListener(ctx)
if err != nil {
var genErr *fmt.wrapError
if errors.As(err, &genErr) && strings.Contains(err.Error(), "error generating random string") {
// OS RNG failure: log, fix environment, retry later
}
} Prevention
- Ensure /dev/urandom is available in containers/sandboxes
- Treat this as an OS-level red flag; investigate the environment, not the library
- Add alerting if it recurs — it should essentially never happen
When it happens
Trigger: utilfn.RandomHexString(16) returns an error during OpenDomainSocketListener, e.g. crypto/rand read failure on the local machine.
Common situations: Depleted or broken /dev/urandom, sandboxed environments restricting crypto/rand, severe OS resource exhaustion.
Related errors
- failed to generate job auth token: %w
- setting auth key: %v
- error setting jwt public key: %v
- no WAVETERM_TABID env var set
- no WAVETERM_TABID env var set
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/d835773c5785f9df.
Report an issue: GitHub.