Skip to content

Unhandled async: chainlink-feed.ts — fire-and-forget this.connect() in scheduleReconnect setTimeout #293

@realfishsam

Description

@realfishsam

Risk Level

MEDIUM

Location

core/src/feeds/chainlink/chainlink-feed.ts:312–318

Code

private scheduleReconnect(): void {
    if (this.reconnectTimer) return;
    this.reconnectTimer = setTimeout(() => {
        this.reconnectTimer = null;
        if (!this.isTerminated) this.connect();   // <-- Promise<void> silently discarded
    }, this.reconnectIntervalMs);
}

What Happens on Failure

Identical to the companion issue in BinanceFeed (core/src/feeds/binance/binance-feed.ts:214). this.connect() is async and can reject; the setTimeout callback discards the returned Promise with no .catch(). A failed reconnect attempt vanishes silently. All registered watchTicker subscriptions on the Chainlink feed stop receiving oracle price updates and there is no log entry to indicate the loop has stalled.

Suggested Fix

this.reconnectTimer = setTimeout(() => {
    this.reconnectTimer = null;
    if (!this.isTerminated) {
        this.connect().catch((err: unknown) => {
            console.error('[ChainlinkFeed] reconnect failed:', err instanceof Error ? err.message : String(err));
        });
    }
}, this.reconnectIntervalMs);

Found by automated unhandled async audit

Metadata

Metadata

Assignees

No one assigned

    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