Skip to content

[High Data Loss] Async NATS crash leads to thread never restarting #24399

@octave-ati

Description

@octave-ati

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

Hello,

I have run into this issue when the NATS subject I listen to (when using * or >) is not UTF-8 compatible :

thread 'vector-worker' panicked at /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-nats-0.42.0/src/connection.rs:180:63: called Result::unwrap()on anErrvalue: Utf8Error { valid_up_to: 38, error_len: Some(1) } note: run withRUST_BACKTRACE=1 environment variable to display a backtrace 2025-12-17T13:00:23.962120Z INFO source{component_kind="source" component_id=balance component_type=nats}: vector::sources::nats::source: NATS source drained and shut down gracefully.

The problem is that the NATS Source thread never restarts after the shut down, which led to huge data loss on our side (about 1 day of data).

Steps to reproduce :

  • Create a NATS source that listens to 'balance.*'
  • nats pub $'balance.\xFF' '{}'

Would it be possible to fix this by handling this error more gracefully and making sure that the thread restarts?

Configuration

[sources.alva_warrants_balance]
    type = "nats"
    subject = "balances.*"
    url = "${NATS_BUSINESS_URL}"
    connection_name = "internal_data_vector"
    queue = "dataplatform_internaldata_vector_queue"
    [sources.alva_warrants_balance.auth]
        strategy = "user_password"
        [sources.alva_warrants_balance.auth.user_password]
            user = "${NATS_BUSINESS_USER}"
            password = "${NATS_BUSINESS_PASSWORD}"

Version

0.49.0

Debug Output

thread 'vector-worker' panicked at /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/async-nats-0.42.0/src/connection.rs:180:63:
called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 38, error_len: Some(1) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2025-12-17T13:00:23.962120Z  INFO source{component_kind="source" component_id=balance component_type=nats}: vector::sources::nats::source: NATS source drained and shut down gracefully.

Example Data

No response

Additional Context

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: natsAnything `nats` source relatedtype: bugA code related bug.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions