Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default maxDelay to max 32-bit signed integer #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/event_retrier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {DroppedError, RetryShutdownError} from "./error";
import {awaitAtMost, pDefer, DeferredPromise} from "./util";
import {
awaitAtMost,
pDefer,
DeferredPromise,
Max32BitSignedInteger,
} from "./util";

/**
* Event retry settings
Expand Down Expand Up @@ -54,7 +59,7 @@ export class EventRetrier {
backoff: 2,
delay: 100,
minDelay: -Infinity,
maxDelay: +Infinity,
maxDelay: Max32BitSignedInteger,
onError: () => {},
...(opts || {}),
};
Expand Down
3 changes: 2 additions & 1 deletion src/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "./error";
import * as protocol from "./protocol";
import {PassThrough, Duplex} from "stream";
import {Max32BitSignedInteger} from "./util";

/**
* Reconnection settings for the socket
Expand Down Expand Up @@ -320,7 +321,7 @@ export class FluentSocket extends EventEmitter {
backoff: 2,
delay: 500, // default is 500ms
minDelay: -Infinity,
maxDelay: +Infinity,
maxDelay: Max32BitSignedInteger,
...(options.reconnect || {}),
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ export const pDefer = <T>(): DeferredPromise<T> => {
});
return deferred as DeferredPromise<T>;
};

export const Max32BitSignedInteger = 2 ** 31 - 1;