<!-- XE-13276 · [net/msg.go] L5: MaxConcurrent=50 tanpa backpressure — resource exhaustion kalau handler lambat · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13276>. The page is the record; this is the same page for reading.*

XE-13276 · Bounty

# \[net/msg.go\] L5: MaxConcurrent\=50 tanpa backpressure — resource exhaustion kalau handler lambat

Closed · invalid
—
[xe#421](https://github.com/xeprotocol/xe/issues/421)
filed 2026-11-12 02:48 UTC
by wahyu20260100233-ops

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:49 UTC

### Patches

None linked.

### History

- [557355](https://bounty.xe.network/log/557355) 2026-11-20 00:49 UTC reply.mirrored
- [557068](https://bounty.xe.network/log/557068) 2026-11-20 00:48 UTC reply.sent
- [554045](https://bounty.xe.network/log/554045) 2026-11-20 00:35 UTC github.state\_pushed
- [554044](https://bounty.xe.network/log/554044) 2026-11-20 00:35 UTC github.labels
- [553337](https://bounty.xe.network/log/553337) 2026-11-20 00:33 UTC proposal.adopted
- [553135](https://bounty.xe.network/log/553135) 2026-11-20 00:33 UTC proposal.adopted
- [553134](https://bounty.xe.network/log/553134) 2026-11-20 00:33 UTC ticket.status new → closed
- [552611](https://bounty.xe.network/log/552611) 2026-11-20 00:33 UTC proposal.adopted
- [552610](https://bounty.xe.network/log/552610) 2026-11-20 00:33 UTC ticket.facts area
- [552605](https://bounty.xe.network/log/552605) 2026-11-20 00:33 UTC proposal.adopted
- [552604](https://bounty.xe.network/log/552604) 2026-11-20 00:33 UTC ticket.facts
- [551045](https://bounty.xe.network/log/551045) 2026-11-20 00:31 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-13276) · [JSON](https://bounty.xe.network/v1/tickets/XE-13276) · [markdown](https://bounty.xe.network/XE-13276.md)

### Report

## Ringkasan

`MaxConcurrent = 50` tapi tidak ada backpressure mechanism kalau handler lambat. Request bisa menumpuk di queue dan menyebabkan memory growth.

## Lokasi

- File: `net/msg.go`
- Lines: 27-28, 157-163

## Kode

```
const (
    requestTimeout = 15 * time.Second
    maxConcurrent  = 50
)

func (m *Messenger) Start(h host.Host, ng *NetworkGater, opts ...Option) {
    ...
    m.inflight = make(chan struct{}, maxConcurrent)
    m.requests = make(chan msgRequest, 1000)  // queue tanpa batas
    ...
}
```

## Impact

Queue `requests` bisa tumbuh tanpa batas kalau handler lambat. Memory growth, potensi OOM.

## Suggested Fix

```
func (m *Messenger) Start(h host.Host, ng *NetworkGater, opts ...Option) {
    ...
    m.inflight = make(chan struct{}, maxConcurrent)
    m.requests = make(chan msgRequest, 1000)
    m.maxQueueSize = 5000  // tambah config
    ...
}

func (m *Messenger) request(pid peer.ID, msgType string, payload interface{}, timeout time.Duration) (json.RawMessage, error) {
    ...
    select {
    case m.requests <- req:
    case <-time.After(100 * time.Millisecond):
        return nil, ErrQueueFull
    }
    ...
}
```

Atau gunakan backpressure: kalau queue penuh, reject request dengan error.

```
m.requests = make(chan msgRequest, 1000)
// di request():
select {
case m.requests <- req:
case <-time.After(100 * time.Millisecond):
    return nil, ErrQueueFull
}
```

### Thread

**XE desk**team2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-13276 and says what; it is read like any other.
