Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

A client reauth over the same socket should not count against their max connections

Chiusa Adatta ai principianti
#342 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@MatthewHarrigan ci sta già lavorando.

Dal 30/9/2026.

  • #341 di @MatthewHarrigan — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js

Direzione di ricerca

Inizia in lib/listener.js, in Sockets.prototype.auth(), che l'issue identifica come il punto in cui lo stesso socket viene aggiunto all'indice dell'utente durante la riautenticazione. Usa il test di riproduzione dell'issue, con auth.index abilitato e maxConnectionsPerUser impostato su 2. Il lavoro è completato quando riautenticazioni ripetute su un socket aperto non superano il limite di connessioni, mentre le connessioni separate continuano a essere conteggiate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Runtime

node

Runtime version

v24.18.1

Module version

v14.0.1

Last module version without issue

N/A

Used with

hapi application

Any other relevant information

See https://github.com/hapijs/nes/pull/341. I commented with a test that reproduces the issue on master:

it('does not count reauthentication towards the connections limit', async () => {

    const server = Hapi.server();

    server.auth.scheme('custom', internals.implementation);
    server.auth.strategy('default', 'custom');
    server.auth.default('default');

    await server.register({ plugin: Nes, options: { auth: { index: true, maxConnectionsPerUser: 2 } } });
    await server.start();

    const client = new Nes.Client(getUri(server.info));
    await client.connect({ reconnect: false, auth: { headers: { authorization: 'Custom john' } } });

    await client.reauthenticate({ headers: { authorization: 'Custom john' } });
    // a reauth is not a new connection
    await expect(client.reauthenticate({ headers: { authorization: 'Custom john' } })).to.not.reject();

    client.disconnect();
    await server.stop();
});
What are you trying to achieve or the steps to reproduce?

With auth.index: true, every reauthenticate() on an open connection pushes the same socket onto the user's index array again. Sockets.prototype.auth() in lib/listener.js doesn't check whether it's already there.

What was the result you got?

Multiple reauths due to token refresh can lead to disconnections due to hitting configured maxConnectionsPerUser when user only has 1 connection open.

An additional side effect is that a broadcast() targeted at a user will cause them to receive duplicate messages due to their socket being duplicated in the _byUser array.

What result did you expect?

I would expect only true connections (multiple tabs open for example) would count towards the limit.

Lingua principale
JavaScript
Stelle
502
Fork
85
Merge medio
16g 16h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hapijs/nes

Tutte le issue di hapijs/nes

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.