Skip to content

[Bug] Cannot use it with libpq #123

@ndrean

Description

@ndrean

I use nats.zig with libpq.

I start a PG conn with libpq, then a nats connection. If I run getStreamInfo(), it hangs, also manager.openBucket().

I can publish a request: PUB $JS.API.STREAM.INFO.KV_schemas _INBOX.xxx 0\r\n\r\n
The NATS server responds with PING\r\n (6 bytes) instead of stream info
nats.zig gets confused and either:

  • Hangs forever waiting for response (most common)
  • Panics with "Attempting to consume 110 bytes but only 6 available"
  • Panics with "reached unreachable code"

I cannot reproduce this if I don't use libpq so can't submit a minimal code.

libpq probably interfers with nats.zig internal state and i likely a race condition because running it several time gives either hanging, buffer panic or unreachable code.

I get things like:

# Run 1: Hangs forever
debug(nats): Published message to $JS.API.STREAM.INFO.KV_schemas with reply _INBOX.9JL2U9VN0UDJ5JUGLZGVVX.0
debug(nats): Read 6 bytes: PING
[freezes]

# Run 2: Panic
thread 57163971 panic: Attempting to consume 110 bytes but only 6 available

# Run 3: Different panic
thread 57379856 panic: reached unreachable code

Note that nats.c does not give me these problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions