Files
homarr/patches/docker-modem@5.0.7.patch
T

28 lines
1.3 KiB
Diff

diff --git a/lib/modem.js b/lib/modem.js
index b45a798d63647d55e0193fd7e82c2e36785d9b5f..d2dbf42969fc0ebf39b30c1a27373c33c2d20333 100644
--- a/lib/modem.js
+++ b/lib/modem.js
@@ -3,7 +3,6 @@ var querystring = require('querystring'),
fs = require('fs'),
path = require('path'),
url = require('url'),
- ssh = require('./ssh'),
HttpDuplex = require('./http_duplex'),
debug = require('debug')('modem'),
utils = require('./utils'),
@@ -263,8 +262,13 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {
var connectionTimeoutTimer;
var finished = false;
+ // Loaded here rather than at module scope: './ssh' pulls in ssh2, whose crypto module
+ // instantiates a ~16 MiB WebAssembly memory for ChaCha20-Poly1305 as soon as it is
+ // required. Measured at +14 MiB RSS for a require alone, paid by every Homarr install
+ // even though Docker is reached over a socket and this branch never runs. require() is
+ // cached, so SSH connections pay it once and behave exactly as before.
var opts = self.protocol === 'ssh' ? Object.assign(options, {
- agent: ssh(Object.assign({}, self.sshOptions, {
+ agent: require('./ssh')(Object.assign({}, self.sshOptions, {
'host': self.host,
'port': self.port,
'username': self.username,