Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tardis-machine

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tardis-machine - npm Package Compare versions

Comparing version 3.7.6 to 3.7.7

1

dist/tardismachine.d.ts

@@ -5,2 +5,3 @@ export declare class TardisMachine {

private readonly _wsServer;
private _eventLoopTimerId;
constructor(options: Options);

@@ -7,0 +8,0 @@ start(port: number): Promise<void>;

@@ -13,2 +13,3 @@ "use strict";

const ws_1 = require("./ws");
const debug_1 = require("./debug");
const pkg = require('../package.json');

@@ -19,2 +20,3 @@ class TardisMachine {

_wsServer;
_eventLoopTimerId = undefined;
constructor(options) {

@@ -75,2 +77,15 @@ this.options = options;

async start(port) {
let start = process.hrtime();
const interval = 500;
// based on https://github.com/tj/node-blocked/blob/master/index.js
this._eventLoopTimerId = setInterval(() => {
const delta = process.hrtime(start);
const nanosec = delta[0] * 1e9 + delta[1];
const ms = nanosec / 1e6;
const n = ms - interval;
if (n > 2000) {
(0, debug_1.debug)('Tardis-machine server event loop blocked for %d ms.', Math.round(n));
}
start = process.hrtime();
}, interval);
if (this.options.clearCache) {

@@ -104,2 +119,5 @@ await (0, tardis_dev_1.clearCache)();

});
if (this._eventLoopTimerId !== undefined) {
clearInterval(this._eventLoopTimerId);
}
}

@@ -106,0 +124,0 @@ }

24

dist/ws/streamnormalized.js

@@ -21,2 +21,4 @@ "use strict";

let subSequentErrorsCount = {};
let retries = 0;
let bufferedAmount = 0;
const messagesIterables = options.map((option) => {

@@ -65,15 +67,17 @@ // let's map from provided options to options and normalizers that needs to be added for dataTypes provided in options

}
const success = ws.send(JSON.stringify(message));
retries = 0;
bufferedAmount = 0;
// handle backpressure in case of slow clients
if (!success) {
let retries = 0;
while (ws.getBufferedAmount() > 0) {
await (0, helpers_1.wait)(20);
retries += 1;
if (retries > 2000) {
ws.end(1008, 'Too much backpressure');
return;
}
while ((bufferedAmount = ws.getBufferedAmount()) > 0) {
retries += 1;
await (0, helpers_1.wait)(10 * retries);
if (retries % 20 === 0 || retries === 5) {
(0, debug_1.debug)('Slow client, waiting %d ms, buffered amount: %d', 10 * retries, bufferedAmount);
}
if (retries > 100) {
ws.end(1008, 'Too much backpressure');
return;
}
}
ws.send(JSON.stringify(message));
if (message.type !== 'disconnect') {

@@ -80,0 +84,0 @@ subSequentErrorsCount[exchange] = 0;

{
"name": "tardis-machine",
"version": "3.7.6",
"version": "3.7.7",
"engines": {

@@ -60,13 +60,13 @@ "node": ">=12"

"debug": "^4.3.4",
"find-my-way": "^5.5.1",
"find-my-way": "^6.3.0",
"is-docker": "^2.2.1",
"tardis-dev": "^13.4.5",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.8.0",
"yargs": "^17.4.1"
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.10.0",
"yargs": "^17.5.1"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/jest": "^27.0.3",
"@types/node": "^17.0.27",
"@types/node-fetch": "^2.5.12",
"@types/jest": "^28.1.1",
"@types/node": "^17.0.41",
"@types/node-fetch": "^2.6.1",
"@types/split2": "^3.2.1",

@@ -76,11 +76,11 @@ "@types/ws": "^8.5.3",

"cross-var": "^1.1.0",
"husky": "^7.0.4",
"jest": "^27.4.5",
"lint-staged": "^12.4.0",
"husky": "^8.0.1",
"jest": "^28.1.1",
"lint-staged": "^13.0.1",
"node-fetch": "^2.6.1",
"prettier": "^2.6.2",
"split2": "^4.1.0",
"ts-jest": "^27.1.2",
"typescript": "^4.6.3",
"ws": "^8.5.0"
"ts-jest": "^28.0.4",
"typescript": "^4.7.3",
"ws": "^8.8.0"
},

@@ -87,0 +87,0 @@ "lint-staged": {

@@ -7,2 +7,3 @@ import findMyWay from 'find-my-way'

import { replayNormalizedWS, replayWS, streamNormalizedWS } from './ws'
import { debug } from './debug'

@@ -14,2 +15,3 @@ const pkg = require('../package.json')

private readonly _wsServer: TemplatedApp
private _eventLoopTimerId: NodeJS.Timer | undefined = undefined

@@ -85,2 +87,19 @@ constructor(private readonly options: Options) {

public async start(port: number) {
let start = process.hrtime()
const interval = 500
// based on https://github.com/tj/node-blocked/blob/master/index.js
this._eventLoopTimerId = setInterval(() => {
const delta = process.hrtime(start)
const nanosec = delta[0] * 1e9 + delta[1]
const ms = nanosec / 1e6
const n = ms - interval
if (n > 2000) {
debug('Tardis-machine server event loop blocked for %d ms.', Math.round(n))
}
start = process.hrtime()
}, interval)
if (this.options.clearCache) {

@@ -114,2 +133,6 @@ await clearCache()

})
if (this._eventLoopTimerId !== undefined) {
clearInterval(this._eventLoopTimerId)
}
}

@@ -116,0 +139,0 @@ }

@@ -21,2 +21,5 @@ import qs from 'querystring'

let retries = 0
let bufferedAmount = 0
const messagesIterables = options.map((option) => {

@@ -81,17 +84,20 @@ // let's map from provided options to options and normalizers that needs to be added for dataTypes provided in options

const success = ws.send(JSON.stringify(message))
retries = 0
bufferedAmount = 0
// handle backpressure in case of slow clients
if (!success) {
let retries = 0
while (ws.getBufferedAmount() > 0) {
await wait(20)
retries += 1
while ((bufferedAmount = ws.getBufferedAmount()) > 0) {
retries += 1
await wait(10 * retries)
if (retries > 2000) {
ws.end(1008, 'Too much backpressure')
return
}
if (retries % 20 === 0 || retries === 5) {
debug('Slow client, waiting %d ms, buffered amount: %d', 10 * retries, bufferedAmount)
}
if (retries > 100) {
ws.end(1008, 'Too much backpressure')
return
}
}
ws.send(JSON.stringify(message))
if (message.type !== 'disconnect') {

@@ -98,0 +104,0 @@ subSequentErrorsCount[exchange] = 0

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc