@dxos/rpc 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33

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.
@@ -1,15 +1,5 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
- // src/rpc.ts
4
- import { asyncTimeout, synchronized, Trigger } from "@dxos/async";
5
- import { Stream } from "@dxos/codec-protobuf";
6
- import { StackTrace as StackTrace2 } from "@dxos/debug";
7
- import { invariant } from "@dxos/invariant";
8
- import { log } from "@dxos/log";
9
- import { encodeError, RpcClosedError, RpcNotOpenError } from "@dxos/protocols";
10
- import { schema } from "@dxos/protocols/proto";
11
- import { exponentialBackoffInterval } from "@dxos/util";
12
-
13
3
  // src/errors.ts
14
4
  import { StackTrace } from "@dxos/debug";
15
5
  import { decodeError } from "@dxos/protocols";
@@ -20,18 +10,30 @@ var decodeRpcError = (err, rpcMethod) => decodeError(err, {
20
10
  });
21
11
 
22
12
  // src/rpc.ts
13
+ import { Trigger, asyncTimeout, synchronized } from "@dxos/async";
14
+ import { Stream } from "@dxos/codec-protobuf";
15
+ import { ContextRpcCodec } from "@dxos/context";
16
+ import { StackTrace as StackTrace2 } from "@dxos/debug";
17
+ import { invariant } from "@dxos/invariant";
18
+ import { log } from "@dxos/log";
19
+ import { RpcClosedError, RpcNotOpenError, encodeError } from "@dxos/protocols";
20
+ import { schema } from "@dxos/protocols/proto";
21
+ import { exponentialBackoffInterval } from "@dxos/util";
22
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/rpc/src/rpc.ts";
23
23
  function _ts_decorate(decorators, target, key, desc) {
24
24
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
25
25
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
26
26
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
27
27
  return c > 3 && r && Object.defineProperty(target, key, r), r;
28
28
  }
29
- var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/rpc/src/rpc.ts";
30
- var DEFAULT_TIMEOUT = 3e3;
29
+ var DEFAULT_TIMEOUT = 3e4;
31
30
  var BYE_SEND_TIMEOUT = 2e3;
32
31
  var DEBUG_CALLS = true;
33
32
  var CLOSE_TIMEOUT = 3e3;
34
33
  var PendingRpcRequest = class {
34
+ resolve;
35
+ reject;
36
+ stream;
35
37
  constructor(resolve, reject, stream) {
36
38
  this.resolve = resolve;
37
39
  this.reject = reject;
@@ -41,22 +43,23 @@ var PendingRpcRequest = class {
41
43
  var RpcMessageCodec;
42
44
  var getRpcMessageCodec = () => RpcMessageCodec ??= schema.getCodecForType("dxos.rpc.RpcMessage");
43
45
  var RpcPeer = class {
46
+ _params;
47
+ _outgoingRequests = /* @__PURE__ */ new Map();
48
+ _localStreams = /* @__PURE__ */ new Map();
49
+ _remoteOpenTrigger = new Trigger();
50
+ /**
51
+ * Triggered when the peer starts closing.
52
+ */
53
+ _closingTrigger = new Trigger();
54
+ /**
55
+ * Triggered when peer receives a bye message.
56
+ */
57
+ _byeTrigger = new Trigger();
58
+ _nextId = 0;
59
+ _state = "INITIAL";
60
+ _unsubscribeFromPort = void 0;
61
+ _clearOpenInterval = void 0;
44
62
  constructor(params) {
45
- this._outgoingRequests = /* @__PURE__ */ new Map();
46
- this._localStreams = /* @__PURE__ */ new Map();
47
- this._remoteOpenTrigger = new Trigger();
48
- /**
49
- * Triggered when the peer starts closing.
50
- */
51
- this._closingTrigger = new Trigger();
52
- /**
53
- * Triggered when peer receives a bye message.
54
- */
55
- this._byeTrigger = new Trigger();
56
- this._nextId = 0;
57
- this._state = "INITIAL";
58
- this._unsubscribeFromPort = void 0;
59
- this._clearOpenInterval = void 0;
60
63
  this._params = {
61
64
  timeout: void 0,
62
65
  streamHandler: void 0,
@@ -77,12 +80,7 @@ var RpcPeer = class {
77
80
  try {
78
81
  await this._receive(msg);
79
82
  } catch (err) {
80
- log.catch(err, void 0, {
81
- F: __dxlog_file,
82
- L: 156,
83
- S: this,
84
- C: (f, a) => f(...a)
85
- });
83
+ log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 100, S: this });
86
84
  }
87
85
  });
88
86
  this._state = "OPENING";
@@ -93,12 +91,7 @@ var RpcPeer = class {
93
91
  }
94
92
  log("sending open message", {
95
93
  state: this._state
96
- }, {
97
- F: __dxlog_file,
98
- L: 168,
99
- S: this,
100
- C: (f, a) => f(...a)
101
- });
94
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 109, S: this });
102
95
  await this._sendMessage({
103
96
  open: true
104
97
  });
@@ -108,12 +101,7 @@ var RpcPeer = class {
108
101
  this._clearOpenInterval = exponentialBackoffInterval(() => {
109
102
  void this._sendMessage({
110
103
  open: true
111
- }).catch((err) => log.warn(err, void 0, {
112
- F: __dxlog_file,
113
- L: 177,
114
- S: this,
115
- C: (f, a) => f(...a)
116
- }));
104
+ }).catch((err) => log.warn(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this }));
117
105
  }, 50);
118
106
  await Promise.race([
119
107
  this._remoteOpenTrigger.wait(),
@@ -125,12 +113,7 @@ var RpcPeer = class {
125
113
  }
126
114
  log("resending open message", {
127
115
  state: this._state
128
- }, {
129
- F: __dxlog_file,
130
- L: 191,
131
- S: this,
132
- C: (f, a) => f(...a)
133
- });
116
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 135, S: this });
134
117
  await this._sendMessage({
135
118
  openAck: true
136
119
  });
@@ -155,32 +138,17 @@ var RpcPeer = class {
155
138
  } catch (err) {
156
139
  log("error closing peer, sending bye", {
157
140
  err
158
- }, {
159
- F: __dxlog_file,
160
- L: 213,
161
- S: this,
162
- C: (f, a) => f(...a)
163
- });
141
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 159, S: this });
164
142
  }
165
143
  try {
166
- log("closing waiting on bye", void 0, {
167
- F: __dxlog_file,
168
- L: 216,
169
- S: this,
170
- C: (f, a) => f(...a)
171
- });
144
+ log("closing waiting on bye", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 164, S: this });
172
145
  await this._byeTrigger.wait({
173
146
  timeout
174
147
  });
175
148
  } catch (err) {
176
149
  log("error closing peer", {
177
150
  err
178
- }, {
179
- F: __dxlog_file,
180
- L: 219,
181
- S: this,
182
- C: (f, a) => f(...a)
183
- });
151
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 169, S: this });
184
152
  return;
185
153
  }
186
154
  }
@@ -217,22 +185,12 @@ var RpcPeer = class {
217
185
  const decoded = getRpcMessageCodec().decode(msg, {
218
186
  preserveAny: true
219
187
  });
220
- DEBUG_CALLS && log("received message", {
188
+ DEBUG_CALLS && log.trace("received message", {
221
189
  type: Object.keys(decoded)[0]
222
- }, {
223
- F: __dxlog_file,
224
- L: 263,
225
- S: this,
226
- C: (f, a) => f(...a)
227
- });
190
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 208, S: this });
228
191
  if (decoded.request) {
229
192
  if (this._state !== "OPENED" && this._state !== "OPENING") {
230
- log("received request while closed", void 0, {
231
- F: __dxlog_file,
232
- L: 267,
233
- S: this,
234
- C: (f, a) => f(...a)
235
- });
193
+ log("received request while closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 213, S: this });
236
194
  await this._sendMessage({
237
195
  response: {
238
196
  id: decoded.request.id,
@@ -245,112 +203,59 @@ var RpcPeer = class {
245
203
  if (req.stream) {
246
204
  log("stream request", {
247
205
  method: req.method
248
- }, {
249
- F: __dxlog_file,
250
- L: 279,
251
- S: this,
252
- C: (f, a) => f(...a)
253
- });
206
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 224, S: this });
254
207
  this._callStreamHandler(req, (response) => {
255
208
  log("sending stream response", {
256
209
  method: req.method,
257
210
  response: response.payload?.type_url,
258
211
  error: response.error,
259
212
  close: response.close
260
- }, {
261
- F: __dxlog_file,
262
- L: 281,
263
- S: this,
264
- C: (f, a) => f(...a)
265
- });
213
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 228, S: this });
266
214
  void this._sendMessage({
267
215
  response
268
216
  }).catch((err) => {
269
- log.warn("failed during close", err, {
270
- F: __dxlog_file,
271
- L: 289,
272
- S: this,
273
- C: (f, a) => f(...a)
274
- });
217
+ log.warn("failed during close", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 237, S: this });
275
218
  });
276
219
  });
277
220
  } else {
278
- DEBUG_CALLS && log("requesting...", {
221
+ DEBUG_CALLS && log.trace("requesting...", {
279
222
  method: req.method
280
- }, {
281
- F: __dxlog_file,
282
- L: 293,
283
- S: this,
284
- C: (f, a) => f(...a)
285
- });
223
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 241, S: this });
286
224
  const response = await this._callHandler(req);
287
- DEBUG_CALLS && log("sending response", {
225
+ DEBUG_CALLS && log.trace("sending response", {
288
226
  method: req.method,
289
227
  response: response.payload?.type_url,
290
228
  error: response.error
291
- }, {
292
- F: __dxlog_file,
293
- L: 296,
294
- S: this,
295
- C: (f, a) => f(...a)
296
- });
229
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 245, S: this });
297
230
  await this._sendMessage({
298
231
  response
299
232
  });
300
233
  }
301
234
  } else if (decoded.response) {
302
235
  if (this._state !== "OPENED") {
303
- log("received response while closed", void 0, {
304
- F: __dxlog_file,
305
- L: 305,
306
- S: this,
307
- C: (f, a) => f(...a)
308
- });
236
+ log("received response while closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 256, S: this });
309
237
  return;
310
238
  }
311
239
  const responseId = decoded.response.id;
312
- invariant(typeof responseId === "number", void 0, {
313
- F: __dxlog_file,
314
- L: 310,
315
- S: this,
316
- A: [
317
- "typeof responseId === 'number'",
318
- ""
319
- ]
320
- });
240
+ invariant(typeof responseId === "number", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 260, S: this, A: ["typeof responseId === 'number'", ""] });
321
241
  if (!this._outgoingRequests.has(responseId)) {
322
- log("received response with invalid id", {
242
+ log.trace("received response with invalid id", {
323
243
  responseId
324
- }, {
325
- F: __dxlog_file,
326
- L: 312,
327
- S: this,
328
- C: (f, a) => f(...a)
329
- });
244
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 262, S: this });
330
245
  return;
331
246
  }
332
247
  const item = this._outgoingRequests.get(responseId);
333
248
  if (!item.stream) {
334
249
  this._outgoingRequests.delete(responseId);
335
250
  }
336
- DEBUG_CALLS && log("response", {
251
+ DEBUG_CALLS && log.trace("response", {
337
252
  type_url: decoded.response.payload?.type_url
338
- }, {
339
- F: __dxlog_file,
340
- L: 322,
341
- S: this,
342
- C: (f, a) => f(...a)
343
- });
253
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 272, S: this });
344
254
  item.resolve(decoded.response);
345
255
  } else if (decoded.open) {
346
256
  log("received open message", {
347
257
  state: this._state
348
- }, {
349
- F: __dxlog_file,
350
- L: 325,
351
- S: this,
352
- C: (f, a) => f(...a)
353
- });
258
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: this });
354
259
  if (this._params.noHandshake) {
355
260
  return;
356
261
  }
@@ -360,12 +265,7 @@ var RpcPeer = class {
360
265
  } else if (decoded.openAck) {
361
266
  log("received openAck message", {
362
267
  state: this._state
363
- }, {
364
- F: __dxlog_file,
365
- L: 332,
366
- S: this,
367
- C: (f, a) => f(...a)
368
- });
268
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 287, S: this });
369
269
  if (this._params.noHandshake) {
370
270
  return;
371
271
  }
@@ -373,41 +273,18 @@ var RpcPeer = class {
373
273
  this._remoteOpenTrigger.wake();
374
274
  } else if (decoded.streamClose) {
375
275
  if (this._state !== "OPENED") {
376
- log("received stream close while closed", void 0, {
377
- F: __dxlog_file,
378
- L: 341,
379
- S: this,
380
- C: (f, a) => f(...a)
381
- });
276
+ log("received stream close while closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 297, S: this });
382
277
  return;
383
278
  }
384
279
  log("received stream close", {
385
280
  id: decoded.streamClose.id
386
- }, {
387
- F: __dxlog_file,
388
- L: 345,
389
- S: this,
390
- C: (f, a) => f(...a)
391
- });
392
- invariant(typeof decoded.streamClose.id === "number", void 0, {
393
- F: __dxlog_file,
394
- L: 346,
395
- S: this,
396
- A: [
397
- "typeof decoded.streamClose.id === 'number'",
398
- ""
399
- ]
400
- });
281
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 300, S: this });
282
+ invariant(typeof decoded.streamClose.id === "number", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 303, S: this, A: ["typeof decoded.streamClose.id === 'number'", ""] });
401
283
  const stream = this._localStreams.get(decoded.streamClose.id);
402
284
  if (!stream) {
403
285
  log("no local stream", {
404
286
  id: decoded.streamClose.id
405
- }, {
406
- F: __dxlog_file,
407
- L: 349,
408
- S: this,
409
- C: (f, a) => f(...a)
410
- });
287
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 306, S: this });
411
288
  return;
412
289
  }
413
290
  this._localStreams.delete(decoded.streamClose.id);
@@ -415,12 +292,7 @@ var RpcPeer = class {
415
292
  } else if (decoded.bye) {
416
293
  this._byeTrigger.wake();
417
294
  if (this._state !== "CLOSING" && this._state !== "CLOSED") {
418
- log("replying to bye", void 0, {
419
- F: __dxlog_file,
420
- L: 359,
421
- S: this,
422
- C: (f, a) => f(...a)
423
- });
295
+ log("replying to bye", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 317, S: this });
424
296
  this._state = "CLOSING";
425
297
  await this._sendMessage({
426
298
  bye: {}
@@ -431,12 +303,7 @@ var RpcPeer = class {
431
303
  } else {
432
304
  log.error("received malformed message", {
433
305
  msg
434
- }, {
435
- F: __dxlog_file,
436
- L: 367,
437
- S: this,
438
- C: (f, a) => f(...a)
439
- });
306
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 326, S: this });
440
307
  throw new Error("Malformed message.");
441
308
  }
442
309
  }
@@ -445,14 +312,9 @@ var RpcPeer = class {
445
312
  * Peer should be open before making this call.
446
313
  */
447
314
  async call(method, request, options) {
448
- DEBUG_CALLS && log("calling...", {
315
+ DEBUG_CALLS && log.trace("calling...", {
449
316
  method
450
- }, {
451
- F: __dxlog_file,
452
- L: 377,
453
- S: this,
454
- C: (f, a) => f(...a)
455
- });
317
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 336, S: this });
456
318
  throwIfNotOpen(this._state);
457
319
  let response;
458
320
  try {
@@ -460,12 +322,23 @@ var RpcPeer = class {
460
322
  const responseReceived = new Promise((resolve, reject) => {
461
323
  this._outgoingRequests.set(id, new PendingRpcRequest(resolve, reject, false));
462
324
  });
325
+ let traceContext;
326
+ try {
327
+ traceContext = options?.ctx ? ContextRpcCodec.encode(options.ctx) : void 0;
328
+ } catch (err) {
329
+ log.warn("failed to encode trace context", {
330
+ err
331
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 351, S: this });
332
+ }
463
333
  const sending = this._sendMessage({
464
334
  request: {
465
335
  id,
466
336
  method,
467
337
  payload: request,
468
- stream: false
338
+ stream: false,
339
+ ...traceContext ? {
340
+ traceContext
341
+ } : {}
469
342
  }
470
343
  });
471
344
  const timeout = options?.timeout ?? this._params.timeout;
@@ -475,15 +348,7 @@ var RpcPeer = class {
475
348
  waiting
476
349
  ]);
477
350
  response = await waiting;
478
- invariant(response.id === id, void 0, {
479
- F: __dxlog_file,
480
- L: 405,
481
- S: this,
482
- A: [
483
- "response.id === id",
484
- ""
485
- ]
486
- });
351
+ invariant(response.id === id, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 375, S: this, A: ["response.id === id", ""] });
487
352
  } catch (err) {
488
353
  if (err instanceof RpcClosedError) {
489
354
  const error = new RpcClosedError();
@@ -538,76 +403,81 @@ ${stack.getStack()}`;
538
403
  }
539
404
  };
540
405
  this._outgoingRequests.set(id, new PendingRpcRequest(onResponse, closeStream, true));
541
- this._sendMessage({
542
- request: {
543
- id,
544
- method,
545
- payload: request,
546
- stream: true
547
- }
548
- }).catch((err) => {
549
- close(err);
550
- });
406
+ let traceContext;
407
+ try {
408
+ traceContext = options?.ctx ? ContextRpcCodec.encode(options.ctx) : void 0;
409
+ } catch (err) {
410
+ log.warn("failed to encode trace context", {
411
+ err
412
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 429, S: this });
413
+ }
414
+ try {
415
+ this._sendMessage({
416
+ request: {
417
+ id,
418
+ method,
419
+ payload: request,
420
+ stream: true,
421
+ ...traceContext ? {
422
+ traceContext
423
+ } : {}
424
+ }
425
+ }).catch((err) => {
426
+ this._outgoingRequests.delete(id);
427
+ close(err);
428
+ });
429
+ } catch (err) {
430
+ this._outgoingRequests.delete(id);
431
+ throw err;
432
+ }
551
433
  return () => {
552
434
  this._sendMessage({
553
435
  streamClose: {
554
436
  id
555
437
  }
556
438
  }).catch((err) => {
557
- log.catch(err, void 0, {
558
- F: __dxlog_file,
559
- L: 478,
560
- S: this,
561
- C: (f, a) => f(...a)
562
- });
439
+ log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 458, S: this });
563
440
  });
564
441
  this._outgoingRequests.delete(id);
565
442
  };
566
443
  });
567
444
  }
568
445
  async _sendMessage(message, timeout) {
569
- DEBUG_CALLS && log("sending message", {
446
+ DEBUG_CALLS && log.trace("sending message", {
570
447
  type: Object.keys(message)[0]
571
- }, {
572
- F: __dxlog_file,
573
- L: 486,
574
- S: this,
575
- C: (f, a) => f(...a)
576
- });
448
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 465, S: this });
577
449
  await this._params.port.send(getRpcMessageCodec().encode(message, {
578
450
  preserveAny: true
579
451
  }), timeout);
580
452
  }
453
+ _getHandlerRpcOptions(req) {
454
+ let traceCtx;
455
+ if (req.traceContext) {
456
+ try {
457
+ traceCtx = ContextRpcCodec.decode(req.traceContext);
458
+ } catch (err) {
459
+ log.warn("failed to decode trace context", {
460
+ traceContext: req.traceContext,
461
+ err
462
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 478, S: this });
463
+ }
464
+ }
465
+ if (!traceCtx && !this._params.handlerRpcOptions) {
466
+ return void 0;
467
+ }
468
+ return {
469
+ ...this._params.handlerRpcOptions,
470
+ ...traceCtx ? {
471
+ ctx: traceCtx
472
+ } : {}
473
+ };
474
+ }
581
475
  async _callHandler(req) {
582
476
  try {
583
- invariant(typeof req.id === "number", void 0, {
584
- F: __dxlog_file,
585
- L: 492,
586
- S: this,
587
- A: [
588
- "typeof req.id === 'number'",
589
- ""
590
- ]
591
- });
592
- invariant(req.payload, void 0, {
593
- F: __dxlog_file,
594
- L: 493,
595
- S: this,
596
- A: [
597
- "req.payload",
598
- ""
599
- ]
600
- });
601
- invariant(req.method, void 0, {
602
- F: __dxlog_file,
603
- L: 494,
604
- S: this,
605
- A: [
606
- "req.method",
607
- ""
608
- ]
609
- });
610
- const response = await this._params.callHandler(req.method, req.payload, this._params.handlerRpcOptions);
477
+ invariant(typeof req.id === "number", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 496, S: this, A: ["typeof req.id === 'number'", ""] });
478
+ invariant(req.payload, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 497, S: this, A: ["req.payload", ""] });
479
+ invariant(req.method, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 498, S: this, A: ["req.method", ""] });
480
+ const response = await this._params.callHandler(req.method, req.payload, this._getHandlerRpcOptions(req));
611
481
  return {
612
482
  id: req.id,
613
483
  payload: response
@@ -621,43 +491,11 @@ ${stack.getStack()}`;
621
491
  }
622
492
  _callStreamHandler(req, callback) {
623
493
  try {
624
- invariant(this._params.streamHandler, "Requests with streaming responses are not supported.", {
625
- F: __dxlog_file,
626
- L: 511,
627
- S: this,
628
- A: [
629
- "this._params.streamHandler",
630
- "'Requests with streaming responses are not supported.'"
631
- ]
632
- });
633
- invariant(typeof req.id === "number", void 0, {
634
- F: __dxlog_file,
635
- L: 512,
636
- S: this,
637
- A: [
638
- "typeof req.id === 'number'",
639
- ""
640
- ]
641
- });
642
- invariant(req.payload, void 0, {
643
- F: __dxlog_file,
644
- L: 513,
645
- S: this,
646
- A: [
647
- "req.payload",
648
- ""
649
- ]
650
- });
651
- invariant(req.method, void 0, {
652
- F: __dxlog_file,
653
- L: 514,
654
- S: this,
655
- A: [
656
- "req.method",
657
- ""
658
- ]
659
- });
660
- const responseStream = this._params.streamHandler(req.method, req.payload, this._params.handlerRpcOptions);
494
+ invariant(this._params.streamHandler, "Requests with streaming responses are not supported.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 513, S: this, A: ["this._params.streamHandler", "'Requests with streaming responses are not supported.'"] });
495
+ invariant(typeof req.id === "number", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 514, S: this, A: ["typeof req.id === 'number'", ""] });
496
+ invariant(req.payload, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 515, S: this, A: ["req.payload", ""] });
497
+ invariant(req.method, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 516, S: this, A: ["req.method", ""] });
498
+ const responseStream = this._params.streamHandler(req.method, req.payload, this._getHandlerRpcOptions(req));
661
499
  responseStream.onReady(() => {
662
500
  callback({
663
501
  id: req.id,
@@ -713,6 +551,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
713
551
  var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/rpc/src/service.ts";
714
552
  var createServiceBundle = (services) => services;
715
553
  var ProtoRpcPeer = class {
554
+ rpc;
555
+ _peer;
716
556
  constructor(rpc, _peer) {
717
557
  this.rpc = rpc;
718
558
  this._peer = _peer;
@@ -730,15 +570,7 @@ var ProtoRpcPeer = class {
730
570
  var createProtoRpcPeer = ({ requested, exposed, handlers, encodingOptions, ...rest }) => {
731
571
  const exposedRpcs = {};
732
572
  if (exposed) {
733
- invariant2(handlers, void 0, {
734
- F: __dxlog_file2,
735
- L: 93,
736
- S: void 0,
737
- A: [
738
- "handlers",
739
- ""
740
- ]
741
- });
573
+ invariant2(handlers, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0, A: ["handlers", ""] });
742
574
  for (const serviceName of Object.keys(exposed)) {
743
575
  const serviceFqn = exposed[serviceName].serviceProto.fullName.slice(1);
744
576
  const serviceProvider = handlers[serviceName];
@@ -873,9 +705,11 @@ var encodeMessage = (msg) => isNode() ? Buffer.from(msg) : new TextEncoder().enc
873
705
  import { Event } from "@dxos/async";
874
706
  import { MessageTrace } from "@dxos/protocols/proto/dxos/rpc";
875
707
  var PortTracer = class {
708
+ _wrappedPort;
709
+ message = new Event();
710
+ _port;
876
711
  constructor(_wrappedPort) {
877
712
  this._wrappedPort = _wrappedPort;
878
- this.message = new Event();
879
713
  this._port = {
880
714
  send: (msg) => {
881
715
  this.message.emit({