@johnhenry/wsh 0.19.0 → 0.19.1
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 +1 -1
- package/src/client.mjs +6 -2
package/package.json
CHANGED
package/src/client.mjs
CHANGED
|
@@ -1810,6 +1810,9 @@ export class WshClient {
|
|
|
1810
1810
|
async fileOperation(op, path, opts = {}, timeout = DEFAULT_OPEN_TIMEOUT) {
|
|
1811
1811
|
this.#assertAuthenticated('fileOperation');
|
|
1812
1812
|
const channelId = this._nextChannelId();
|
|
1813
|
+
// FileOp and FileResult both carry channel_id; each call claims only the
|
|
1814
|
+
// result for its own id, so overlapping operations cannot swap replies (#72).
|
|
1815
|
+
const byChannel = (m) => m.channel_id === channelId;
|
|
1813
1816
|
|
|
1814
1817
|
if (op === 'write' || op === 'rename') {
|
|
1815
1818
|
const feature = op === 'write' ? 'file-write' : 'file-rename';
|
|
@@ -1824,7 +1827,7 @@ export class WshClient {
|
|
|
1824
1827
|
}
|
|
1825
1828
|
// Registered before sending: the host may fail fast (read-only, too big)
|
|
1826
1829
|
// and answer before the last chunk goes out.
|
|
1827
|
-
const result = this.#waitForMessage([MSG.FILE_RESULT], timeout, `Timed out waiting for file ${op} result
|
|
1830
|
+
const result = this.#waitForMessage([MSG.FILE_RESULT], timeout, `Timed out waiting for file ${op} result`, byChannel);
|
|
1828
1831
|
result.catch(() => {});
|
|
1829
1832
|
await this.#transport.sendControl(fileOpMsg({
|
|
1830
1833
|
channelId, op, path, offset: op === 'write' ? opts.offset : undefined, length: data.byteLength,
|
|
@@ -1846,7 +1849,8 @@ export class WshClient {
|
|
|
1846
1849
|
return this.#waitForMessage(
|
|
1847
1850
|
[MSG.FILE_RESULT],
|
|
1848
1851
|
timeout,
|
|
1849
|
-
`Timed out waiting for file ${op} result
|
|
1852
|
+
`Timed out waiting for file ${op} result`,
|
|
1853
|
+
byChannel
|
|
1850
1854
|
);
|
|
1851
1855
|
}
|
|
1852
1856
|
|