Fixed agent compression on NodeJS v16.
Ylian Saint-Hilaire committed
Aug 17, 2021 at 17:52 UTC
fddf037bb1059961b20612e9e89434ec76cee76f
1 file changed
+9
-1
meshcentral.js
+9
-1
@@ -2671,7 +2671,15 @@ function CreateMeshCentralServer(config, args) {
2671
archive.on('data', onZipData);
2672
archive.on('end', onZipEnd);
2673
archive.on('error', onZipError);
2674
- archive.append(this.meshAgentBinary.data, { name: 'meshagent' });
2674
+
2675
+ // Starting with NodeJS v16, passing in a buffer at archive.append() will result a compressed file with zero byte length. To fix this, we pass in the buffer as a stream.
2676
+ // archive.append(this.meshAgentBinary.data, { name: 'meshagent' }); // This is the version that does not work on NodeJS v16.
2677
+ const ReadableStream = require('stream').Readable;
2678
+ const zipInputStream = new ReadableStream();
2679
+ zipInputStream.push(this.meshAgentBinary.data);
2680
+ zipInputStream.push(null);
2681
+ archive.append(zipInputStream, { name: 'meshagent' });
2682
+
2683
archive.finalize();
2684
})
2685
obj.exeHandler.streamExeWithMeshPolicy(