@agoric/internal 0.3.3-dev-cb1866d.0.cb1866d → 0.3.3-dev-588c42f.0.588c42f
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/package.json +4 -4
- package/src/lib-nodejs/spawnSubprocessWorker.js +2 -2
- package/src/lib-nodejs/worker-protocol.js +4 -4
- package/src/marshal/wrap-marshaller.d.ts.map +1 -1
- package/src/marshal/wrap-marshaller.js +1 -1
- package/src/netstring.js +4 -4
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +50 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-588c42f.0.588c42f",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:types": "yarn run -T tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-588c42f.0.588c42f",
|
|
24
24
|
"@endo/cache-map": "^1.1.0",
|
|
25
25
|
"@endo/common": "^1.2.13",
|
|
26
26
|
"@endo/compartment-mapper": "^1.6.3",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"jessie.js": "^0.3.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
41
|
+
"@agoric/cosmic-proto": "0.4.1-dev-588c42f.0.588c42f",
|
|
42
42
|
"@endo/exo": "^1.5.12",
|
|
43
43
|
"@endo/init": "^1.1.12",
|
|
44
44
|
"@endo/ses-ava": "^1.3.2",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"typeCoverage": {
|
|
67
67
|
"atLeast": 92.84
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "588c42f376700adc36f9a847e3a66d973d3cee12"
|
|
70
70
|
}
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
// JSON-serializable data.
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line no-unused-vars
|
|
22
|
-
function parentLog(
|
|
23
|
-
// console.error(`--parent: ${
|
|
22
|
+
function parentLog(_first, ..._args) {
|
|
23
|
+
// console.error(`--parent: ${_first}`, ..._args);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// we send on fd3, and receive on fd4. We pass fd1/2 (stdout/err) through, so
|
|
@@ -7,11 +7,11 @@ import { Transform } from 'stream';
|
|
|
7
7
|
export function arrayEncoderStream() {
|
|
8
8
|
/**
|
|
9
9
|
* @param {any} object
|
|
10
|
-
* @param {BufferEncoding}
|
|
10
|
+
* @param {BufferEncoding} _encoding
|
|
11
11
|
* @param {any} callback
|
|
12
12
|
* @this {{ push: (b: Buffer) => void }}
|
|
13
13
|
*/
|
|
14
|
-
function transform(object,
|
|
14
|
+
function transform(object, _encoding, callback) {
|
|
15
15
|
if (!Array.isArray(object)) {
|
|
16
16
|
throw Error('stream requires Arrays');
|
|
17
17
|
}
|
|
@@ -30,11 +30,11 @@ export function arrayEncoderStream() {
|
|
|
30
30
|
export function arrayDecoderStream() {
|
|
31
31
|
/**
|
|
32
32
|
* @param {Buffer} buf
|
|
33
|
-
* @param {BufferEncoding}
|
|
33
|
+
* @param {BufferEncoding} _encoding
|
|
34
34
|
* @param {any} callback
|
|
35
35
|
* @this {{ push: (b: Buffer) => void }}
|
|
36
36
|
*/
|
|
37
|
-
function transform(buf,
|
|
37
|
+
function transform(buf, _encoding, callback) {
|
|
38
38
|
let err;
|
|
39
39
|
try {
|
|
40
40
|
if (!Buffer.isBuffer(buf)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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IACH,0CAHW,WAAW,CAAC,MAAI,CAAC,GACf,MAAI,CAIhB;IArBD;;;OAGG;IACH,kBAHW,IAAI,UACJ,MAAM,EAUhB;IAfD,4BAA4B;IAC5B,sBADW,aAAa,CACsB;;CAwB/C;gCA7CsC,kBAAkB"}
|
package/src/netstring.js
CHANGED
|
@@ -21,11 +21,11 @@ export function encode(data) {
|
|
|
21
21
|
export function netstringEncoderStream() {
|
|
22
22
|
/**
|
|
23
23
|
* @param {Buffer} chunk
|
|
24
|
-
* @param {BufferEncoding}
|
|
24
|
+
* @param {BufferEncoding} _encoding
|
|
25
25
|
* @param {any} callback
|
|
26
26
|
* @this {{ push: (b: Buffer) => void }}
|
|
27
27
|
*/
|
|
28
|
-
function transform(chunk,
|
|
28
|
+
function transform(chunk, _encoding, callback) {
|
|
29
29
|
if (!Buffer.isBuffer(chunk)) {
|
|
30
30
|
throw Error('stream requires Buffers');
|
|
31
31
|
}
|
|
@@ -93,11 +93,11 @@ export function netstringDecoderStream(optMaxChunkSize) {
|
|
|
93
93
|
let buffered = Buffer.from('');
|
|
94
94
|
/**
|
|
95
95
|
* @param {Buffer} chunk
|
|
96
|
-
* @param {BufferEncoding}
|
|
96
|
+
* @param {BufferEncoding} _encoding
|
|
97
97
|
* @param {any} callback
|
|
98
98
|
* @this {{ push: (b: Buffer) => void }}
|
|
99
99
|
*/
|
|
100
|
-
function transform(chunk,
|
|
100
|
+
function transform(chunk, _encoding, callback) {
|
|
101
101
|
if (!Buffer.isBuffer(chunk)) {
|
|
102
102
|
throw Error('stream requires Buffers');
|
|
103
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAcO,sCAHI,UAAU,GAAG,WAAW,GAAG,MAAM,GAC/B,OAAO,CAAC,IAAI,CAAC,CAgCtB;
|
|
1
|
+
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAcO,sCAHI,UAAU,GAAG,WAAW,GAAG,MAAM,GAC/B,OAAO,CAAC,IAAI,CAAC,CAgCtB;AAmDG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eAsEpC;6BAvEa,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;gCAxF5C,IAAI;iCACH,IAAI;4BACT,KAAK"}
|
package/src/node/fs-stream.js
CHANGED
|
@@ -44,6 +44,53 @@ export const fsStreamReady = stream =>
|
|
|
44
44
|
stream.on('error', onError);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Wait for a stream event and reject on stream error first.
|
|
49
|
+
*
|
|
50
|
+
* @param {ReadStream | WriteStream | Socket} stream
|
|
51
|
+
* @param {'drain' | 'ready'} eventName
|
|
52
|
+
* @returns {Promise<void>}
|
|
53
|
+
*/
|
|
54
|
+
const onceWithError = (stream, eventName) =>
|
|
55
|
+
new Promise((resolve, reject) => {
|
|
56
|
+
const onEvent = () => {
|
|
57
|
+
cleanup();
|
|
58
|
+
resolve();
|
|
59
|
+
};
|
|
60
|
+
/** @param {Error} err */
|
|
61
|
+
const onError = err => {
|
|
62
|
+
cleanup();
|
|
63
|
+
reject(err);
|
|
64
|
+
};
|
|
65
|
+
const cleanup = () => {
|
|
66
|
+
stream.off(eventName, onEvent);
|
|
67
|
+
stream.off('error', onError);
|
|
68
|
+
};
|
|
69
|
+
stream.on(eventName, onEvent);
|
|
70
|
+
stream.on('error', onError);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {WriteStream | Socket} stream
|
|
75
|
+
* @param {string | Uint8Array} data
|
|
76
|
+
* @returns {Promise<boolean>} whether caller must await drain
|
|
77
|
+
*/
|
|
78
|
+
const writeChunk = (stream, data) =>
|
|
79
|
+
new Promise((resolve, reject) => {
|
|
80
|
+
let waitForDrain;
|
|
81
|
+
try {
|
|
82
|
+
waitForDrain = !stream.write(data, err => {
|
|
83
|
+
if (err) {
|
|
84
|
+
reject(err);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
resolve(waitForDrain);
|
|
88
|
+
});
|
|
89
|
+
} catch (err) {
|
|
90
|
+
reject(err);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
47
94
|
/** @typedef {NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>} FsStreamWriter */
|
|
48
95
|
/** @param {string | undefined | null} filePath */
|
|
49
96
|
export const makeFsStreamWriter = async filePath => {
|
|
@@ -60,7 +107,7 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
60
107
|
return { handle: fh, stream: fh.createWriteStream({ flush: true }) };
|
|
61
108
|
})();
|
|
62
109
|
await fsStreamReady(stream);
|
|
63
|
-
const
|
|
110
|
+
const waitForDrainAsync = () => onceWithError(stream, 'drain');
|
|
64
111
|
const closeAsync =
|
|
65
112
|
useStdout || !(/** @type {any} */ (stream).close)
|
|
66
113
|
? undefined
|
|
@@ -87,11 +134,11 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
87
134
|
const write = async data => {
|
|
88
135
|
const written = closed
|
|
89
136
|
? Promise.reject(Error('Stream closed'))
|
|
90
|
-
:
|
|
137
|
+
: writeChunk(stream, data);
|
|
91
138
|
updateFlushed(written);
|
|
92
139
|
const waitForDrain = await written;
|
|
93
140
|
if (waitForDrain) {
|
|
94
|
-
await
|
|
141
|
+
await waitForDrainAsync();
|
|
95
142
|
}
|
|
96
143
|
};
|
|
97
144
|
|