Skip to content

Commit

Permalink
fix ERR_STRING_TOO_LONG from docker response
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojacobi committed Apr 23, 2024
1 parent 049e1aa commit fb6d203
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
22 changes: 12 additions & 10 deletions lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ var querystring = require('querystring'),
splitca = require('split-ca'),
os = require('os'),
isWin = os.type() === 'Windows_NT',
stream = require('stream');
stream = require('stream'),
streamJson = require('stream-json'),
Asm = require('stream-json/Assembler');

var defaultOpts = function () {
var host;
Expand Down Expand Up @@ -336,15 +338,15 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {

res.on('end', function () {
var buffer = Buffer.concat(chunks);
var result = buffer.toString();

debug('Received: %s', result);

var json = utils.parseJSON(result) || buffer;
if (finished === false) {
finished = true;
self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);
}
var parser = stream.Readable.from(buffer).pipe(streamJson.parser());
var asm = Asm.connectTo(parser);
asm.on('done', asm => {
var json = asm.current || buffer;
if (finished === false) {
finished = true;
self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);
}
});
});
}
});
Expand Down
20 changes: 17 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"debug": "^4.1.1",
"readable-stream": "^3.5.0",
"split-ca": "^1.0.1",
"ssh2": "^1.15.0"
"ssh2": "^1.15.0",
"stream-json": "^1.8.0"
},
"devDependencies": {
"chai": "~4.2.0",
Expand Down

0 comments on commit fb6d203

Please sign in to comment.