diff --git a/README.md b/README.md index 264f756..6f0ba2d 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Every one is optional. | `shutdownTimeout` | `5000` | How long `close()` and `unbind()` wait for the requests this end already sent; `0` waits forever. | | `maxOutstanding` | `10` | Requests allowed on the wire at once; further sends queue. | | `smsIdFormat` | — | The notation the SMSC writes message ids in, per place it writes them: `{ receipt: 'decimal', submitResp: 'hex' }`. Only needed where the two disagree. | -| `reconnect` | on | Re-binds after a drop, an idle timeout, or a stream the library cannot read, backing off from `minDelay` 1 s to `maxDelay` 30 s. `{ minDelay, maxDelay }` retunes it; `false` turns it off, so a drop ends the session. | +| `reconnect` | on | Re-binds after a drop, an idle timeout, or a stream the library cannot read, backing off from `minDelay` 1 s to `maxDelay` 30 s and starting over at `minDelay` once a link has lasted `maxDelay`. `{ minDelay, maxDelay }` retunes it; `false` turns it off, so a drop ends the session. | | `log` | silent | Any object with `debug`, `error`, `info`, `verbose` and `warn` methods — see [Logging](#logging). | | `signal` | — | An `AbortSignal` that cancels connecting and tears the session down. | diff --git a/test/session-extras.test.ts b/test/session-extras.test.ts index fe709eb..3f0dae6 100644 --- a/test/session-extras.test.ts +++ b/test/session-extras.test.ts @@ -69,6 +69,9 @@ function delay(ms: number): Promise { return new Promise(resolve => { setTimeout(resolve, ms); }); } +/** A cmd_length below the 16-octet header: a stream no framing can recover from. */ +const unreadablePdu = Buffer.from([0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1]); + /** The server's side of the one connection under test. */ function peerOf(smpp: SmppServer): Session { const [peer] = smpp.sessions; @@ -402,8 +405,7 @@ describe('reconnect', () => { const reconnected = once(resolve => { session.on('reconnected', () => { resolve(true); }); }); - // A cmd_length below the 16-octet header is a stream no framing can recover from. - peerOf(smpp).sock.write(Buffer.from([0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1])); + peerOf(smpp).sock.write(unreadablePdu); await reconnected; assert.deepEqual(events, ['sessionError']); @@ -448,8 +450,7 @@ describe('reconnect', () => { const closed = once(resolve => { session.on('close', () => { resolve(true); }); }); - // A cmd_length below the 16-octet header: unreadable, and nothing left to retry it. - peerOf(smpp).sock.write(Buffer.from([0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1])); + peerOf(smpp).sock.write(unreadablePdu); await closed; assert.equal(disconnects, 0); diff --git a/test/session.test.ts b/test/session.test.ts index 3579c4b..6f1084b 100644 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -1374,7 +1374,6 @@ describe('application hooks that throw or reject', () => { }); test('keeps backing off when every link dies as soon as it comes up', async t => { - // A stream we cannot read is found after the bind, so a bind alone must not prove the link. const clock = { now: 0 }; const delays: number[] = []; const noop = (): void => undefined;