Skip to content
Open
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
10 changes: 5 additions & 5 deletions packages/rsocket-core/src/RSocketSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class LeaseHandler implements LeaseManager {
) {}

handle(frame: LeaseFrame): void {
this.expirationTime = frame.ttl + Date.now();
this.expirationTime = frame.ttl + performance.now();
this.availableLease = frame.requestCount;

while (this.availableLease > 0 && this.pendingRequests.length > 0) {
Expand All @@ -213,7 +213,7 @@ export class LeaseHandler implements LeaseManager {

requestLease(handler: StreamFrameHandler & StreamLifecycleHandler): void {
const availableLease = this.availableLease;
if (availableLease > 0 && Date.now() < this.expirationTime) {
if (availableLease > 0 && performance.now() < this.expirationTime) {
this.availableLease = availableLease - 1;
this.multiplexer.createRequestStream(handler);
return;
Expand Down Expand Up @@ -414,7 +414,7 @@ export class KeepAliveHandler implements FrameHandler {
}

handle(frame: KeepAliveFrame): void {
this.keepAliveLastReceivedMillis = Date.now();
this.keepAliveLastReceivedMillis = performance.now();
if (Flags.hasRespond(frame.flags)) {
this.outbound.send({
type: FrameTypes.KEEPALIVE,
Expand All @@ -431,7 +431,7 @@ export class KeepAliveHandler implements FrameHandler {
return;
}

this.keepAliveLastReceivedMillis = Date.now();
this.keepAliveLastReceivedMillis = performance.now();
this.state = KeepAliveHandlerStates.Running;
this.activeTimeout = setTimeout(
this.timeoutCheck.bind(this),
Expand All @@ -454,7 +454,7 @@ export class KeepAliveHandler implements FrameHandler {
}

private timeoutCheck() {
const now = Date.now();
const now = performance.now();
const noKeepAliveDuration = now - this.keepAliveLastReceivedMillis;
if (noKeepAliveDuration >= this.keepAliveTimeoutDuration) {
this.connection.close(
Expand Down