@dxos/rpc 0.8.4-main.3f58842 → 0.8.4-main.3fbcb4aa9b

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