@jsforce/jsforce-node 3.10.12-dev.0 → 3.10.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/VERSION.d.ts +1 -1
- package/lib/VERSION.js +1 -1
- package/lib/request-helper.js +6 -0
- package/lib/util/stream.js +16 -2
- package/package.json +12 -1
package/lib/VERSION.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "3.10.
|
|
1
|
+
declare const _default: "3.10.13";
|
|
2
2
|
export default _default;
|
package/lib/VERSION.js
CHANGED
package/lib/request-helper.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.executeWithTimeout = exports.performRedirectRequest = exports.isRedirect
|
|
|
7
7
|
const stream_1 = require("stream");
|
|
8
8
|
const stream_2 = require("./util/stream");
|
|
9
9
|
const form_data_1 = __importDefault(require("form-data"));
|
|
10
|
+
const logger_1 = require("./util/logger");
|
|
11
|
+
const logger = (0, logger_1.getLogger)('request-helper');
|
|
10
12
|
/**
|
|
11
13
|
*
|
|
12
14
|
*/
|
|
@@ -27,7 +29,11 @@ function createHttpRequestHandlerStreams(req, options = {}) {
|
|
|
27
29
|
}
|
|
28
30
|
duplex.on('response', async (res) => {
|
|
29
31
|
if (duplex.listenerCount('complete') > 0) {
|
|
32
|
+
logger.debug('Processing response');
|
|
33
|
+
const start = Date.now();
|
|
30
34
|
const resBody = await (0, stream_2.readAll)(duplex, options.encoding);
|
|
35
|
+
logger.debug(`Response body read: ${(resBody.length / 1024 / 1024).toFixed(1)}MB ` +
|
|
36
|
+
`in ${Date.now() - start}ms`);
|
|
31
37
|
duplex.emit('complete', {
|
|
32
38
|
...res,
|
|
33
39
|
body: resBody,
|
package/lib/util/stream.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.concatStreamsAsDuplex = exports.readAll = exports.createLazyStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
|
+
const logger = (0, logger_1.getLogger)('stream');
|
|
5
7
|
function createLazyStream() {
|
|
6
8
|
const ins = new stream_1.PassThrough();
|
|
7
9
|
const outs = new stream_1.PassThrough();
|
|
@@ -19,17 +21,21 @@ function createLazyStream() {
|
|
|
19
21
|
exports.createLazyStream = createLazyStream;
|
|
20
22
|
class MemoryWriteStream extends stream_1.Writable {
|
|
21
23
|
_chunks;
|
|
24
|
+
_totalBytes;
|
|
22
25
|
constructor() {
|
|
23
26
|
super();
|
|
24
27
|
this._chunks = [];
|
|
28
|
+
this._totalBytes = 0;
|
|
25
29
|
}
|
|
26
30
|
_write(chunk, encoding, callback) {
|
|
27
31
|
this._chunks.push(chunk);
|
|
32
|
+
this._totalBytes += chunk.length;
|
|
28
33
|
callback();
|
|
29
34
|
}
|
|
30
35
|
_writev(data, callback) {
|
|
31
36
|
for (const { chunk } of data) {
|
|
32
37
|
this._chunks.push(chunk);
|
|
38
|
+
this._totalBytes += chunk.length;
|
|
33
39
|
}
|
|
34
40
|
callback();
|
|
35
41
|
}
|
|
@@ -38,11 +44,19 @@ class MemoryWriteStream extends stream_1.Writable {
|
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
async function readAll(rs, encoding = 'utf-8') {
|
|
47
|
+
logger.debug('readAll: starting to read stream');
|
|
48
|
+
const start = Date.now();
|
|
41
49
|
return new Promise((resolve, reject) => {
|
|
42
50
|
const ws = new MemoryWriteStream();
|
|
43
|
-
rs.on('error',
|
|
51
|
+
rs.on('error', (err) => {
|
|
52
|
+
logger.error(`readAll: stream error: ${(err).message}`);
|
|
53
|
+
reject(err);
|
|
54
|
+
})
|
|
44
55
|
.pipe(ws)
|
|
45
|
-
.on('finish', () =>
|
|
56
|
+
.on('finish', () => {
|
|
57
|
+
logger.debug(`readAll: stream finished in ${Date.now() - start}ms`);
|
|
58
|
+
resolve(ws.toString(encoding));
|
|
59
|
+
});
|
|
46
60
|
});
|
|
47
61
|
}
|
|
48
62
|
exports.readAll = readAll;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"database.com"
|
|
11
11
|
],
|
|
12
12
|
"homepage": "http://github.com/jsforce/jsforce",
|
|
13
|
-
"version": "3.10.
|
|
13
|
+
"version": "3.10.13",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git://github.com/jsforce/jsforce.git"
|
|
@@ -100,6 +100,16 @@
|
|
|
100
100
|
],
|
|
101
101
|
"output": []
|
|
102
102
|
},
|
|
103
|
+
"test:node:perf": {
|
|
104
|
+
"command": "jest test/perf --config {}",
|
|
105
|
+
"dependencies": [
|
|
106
|
+
"build:node:cjs"
|
|
107
|
+
],
|
|
108
|
+
"files": [
|
|
109
|
+
"test/perf/**/*.test.ts"
|
|
110
|
+
],
|
|
111
|
+
"output": []
|
|
112
|
+
},
|
|
103
113
|
"test:browser": {
|
|
104
114
|
"command": "karma start",
|
|
105
115
|
"dependencies": [
|
|
@@ -170,6 +180,7 @@
|
|
|
170
180
|
"lint": "wireit",
|
|
171
181
|
"test": "wireit",
|
|
172
182
|
"test:node": "wireit",
|
|
183
|
+
"test:node:perf": "wireit",
|
|
173
184
|
"test:browser": "wireit",
|
|
174
185
|
"test:browser-ci": "wireit",
|
|
175
186
|
"test:browser-ci:retry": "wireit",
|