@volter/teams 0.2.35 → 0.2.36

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.
Files changed (2) hide show
  1. package/client.mjs +11 -1
  2. package/package.json +1 -1
package/client.mjs CHANGED
@@ -62,10 +62,19 @@ import { lineSplitter } from './lines.mjs';
62
62
  */
63
63
  export function harnessTransport(channel) {
64
64
  let stream = null;
65
+ // Each start and close moves the generation on: a stream whose open was overtaken by a close is closed as it arrives,
66
+ // so a start the client gave up on (its start timeout) leaves no harness stream open on the machine.
67
+ let generation = 0;
65
68
  return {
66
69
  get running() { return stream !== null && !stream.closed; },
67
70
  async start(handlers) {
68
- stream = await channel.open('harness');
71
+ const mine = ++generation;
72
+ const opened = await channel.open('harness');
73
+ if (mine !== generation) {
74
+ opened.close();
75
+ throw new Error('harness stream was closed while it opened');
76
+ }
77
+ stream = opened;
69
78
  const lines = lineSplitter();
70
79
  stream.on('data', (chunk) => {
71
80
  for (const line of lines(chunk)) if (line) handlers.onLine(line);
@@ -77,6 +86,7 @@ export function harnessTransport(channel) {
77
86
  stream.write(line.endsWith('\n') ? line : line + '\n');
78
87
  },
79
88
  async close() {
89
+ generation += 1;
80
90
  stream?.close();
81
91
  stream = null;
82
92
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/teams",
3
- "version": "0.2.35",
3
+ "version": "0.2.36",
4
4
  "type": "module",
5
5
  "description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
6
6
  "license": "MIT",