@dxos/rpc 0.8.4-staging.ac66bdf99f → 0.9.1-main.c7dcc2e112
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/LICENSE +102 -5
- package/dist/lib/neutral/index.mjs +50 -288
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/rpc.d.ts +0 -3
- package/dist/types/src/rpc.d.ts.map +1 -1
- package/dist/types/src/service.d.ts +2 -2
- package/dist/types/src/service.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/trace.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -14
- package/src/rpc.ts +8 -8
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -19,13 +19,13 @@ import { log } from "@dxos/log";
|
|
|
19
19
|
import { RpcClosedError, RpcNotOpenError, encodeError } from "@dxos/protocols";
|
|
20
20
|
import { schema } from "@dxos/protocols/proto";
|
|
21
21
|
import { exponentialBackoffInterval } from "@dxos/util";
|
|
22
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/rpc/src/rpc.ts";
|
|
22
23
|
function _ts_decorate(decorators, target, key, desc) {
|
|
23
24
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
25
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
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;
|
|
26
27
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
28
|
}
|
|
28
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/rpc/src/rpc.ts";
|
|
29
29
|
var DEFAULT_TIMEOUT = 3e4;
|
|
30
30
|
var BYE_SEND_TIMEOUT = 2e3;
|
|
31
31
|
var DEBUG_CALLS = true;
|
|
@@ -80,12 +80,7 @@ var RpcPeer = class {
|
|
|
80
80
|
try {
|
|
81
81
|
await this._receive(msg);
|
|
82
82
|
} catch (err) {
|
|
83
|
-
log.catch(err, void 0, {
|
|
84
|
-
F: __dxlog_file,
|
|
85
|
-
L: 157,
|
|
86
|
-
S: this,
|
|
87
|
-
C: (f, a) => f(...a)
|
|
88
|
-
});
|
|
83
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 100, S: this });
|
|
89
84
|
}
|
|
90
85
|
});
|
|
91
86
|
this._state = "OPENING";
|
|
@@ -96,12 +91,7 @@ var RpcPeer = class {
|
|
|
96
91
|
}
|
|
97
92
|
log("sending open message", {
|
|
98
93
|
state: this._state
|
|
99
|
-
}, {
|
|
100
|
-
F: __dxlog_file,
|
|
101
|
-
L: 169,
|
|
102
|
-
S: this,
|
|
103
|
-
C: (f, a) => f(...a)
|
|
104
|
-
});
|
|
94
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 109, S: this });
|
|
105
95
|
await this._sendMessage({
|
|
106
96
|
open: true
|
|
107
97
|
});
|
|
@@ -111,12 +101,7 @@ var RpcPeer = class {
|
|
|
111
101
|
this._clearOpenInterval = exponentialBackoffInterval(() => {
|
|
112
102
|
void this._sendMessage({
|
|
113
103
|
open: true
|
|
114
|
-
}).catch((err) => log.warn(err, void 0, {
|
|
115
|
-
F: __dxlog_file,
|
|
116
|
-
L: 178,
|
|
117
|
-
S: this,
|
|
118
|
-
C: (f, a) => f(...a)
|
|
119
|
-
}));
|
|
104
|
+
}).catch((err) => log.warn(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this }));
|
|
120
105
|
}, 50);
|
|
121
106
|
await Promise.race([
|
|
122
107
|
this._remoteOpenTrigger.wait(),
|
|
@@ -128,12 +113,7 @@ var RpcPeer = class {
|
|
|
128
113
|
}
|
|
129
114
|
log("resending open message", {
|
|
130
115
|
state: this._state
|
|
131
|
-
}, {
|
|
132
|
-
F: __dxlog_file,
|
|
133
|
-
L: 192,
|
|
134
|
-
S: this,
|
|
135
|
-
C: (f, a) => f(...a)
|
|
136
|
-
});
|
|
116
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 135, S: this });
|
|
137
117
|
await this._sendMessage({
|
|
138
118
|
openAck: true
|
|
139
119
|
});
|
|
@@ -158,32 +138,17 @@ var RpcPeer = class {
|
|
|
158
138
|
} catch (err) {
|
|
159
139
|
log("error closing peer, sending bye", {
|
|
160
140
|
err
|
|
161
|
-
}, {
|
|
162
|
-
F: __dxlog_file,
|
|
163
|
-
L: 214,
|
|
164
|
-
S: this,
|
|
165
|
-
C: (f, a) => f(...a)
|
|
166
|
-
});
|
|
141
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 159, S: this });
|
|
167
142
|
}
|
|
168
143
|
try {
|
|
169
|
-
log("closing waiting on bye", void 0, {
|
|
170
|
-
F: __dxlog_file,
|
|
171
|
-
L: 217,
|
|
172
|
-
S: this,
|
|
173
|
-
C: (f, a) => f(...a)
|
|
174
|
-
});
|
|
144
|
+
log("closing waiting on bye", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 164, S: this });
|
|
175
145
|
await this._byeTrigger.wait({
|
|
176
146
|
timeout
|
|
177
147
|
});
|
|
178
148
|
} catch (err) {
|
|
179
149
|
log("error closing peer", {
|
|
180
150
|
err
|
|
181
|
-
}, {
|
|
182
|
-
F: __dxlog_file,
|
|
183
|
-
L: 220,
|
|
184
|
-
S: this,
|
|
185
|
-
C: (f, a) => f(...a)
|
|
186
|
-
});
|
|
151
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 169, S: this });
|
|
187
152
|
return;
|
|
188
153
|
}
|
|
189
154
|
}
|
|
@@ -220,22 +185,12 @@ var RpcPeer = class {
|
|
|
220
185
|
const decoded = getRpcMessageCodec().decode(msg, {
|
|
221
186
|
preserveAny: true
|
|
222
187
|
});
|
|
223
|
-
DEBUG_CALLS && log("received message", {
|
|
188
|
+
DEBUG_CALLS && log.trace("received message", {
|
|
224
189
|
type: Object.keys(decoded)[0]
|
|
225
|
-
}, {
|
|
226
|
-
F: __dxlog_file,
|
|
227
|
-
L: 264,
|
|
228
|
-
S: this,
|
|
229
|
-
C: (f, a) => f(...a)
|
|
230
|
-
});
|
|
190
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 208, S: this });
|
|
231
191
|
if (decoded.request) {
|
|
232
192
|
if (this._state !== "OPENED" && this._state !== "OPENING") {
|
|
233
|
-
log("received request while closed", void 0, {
|
|
234
|
-
F: __dxlog_file,
|
|
235
|
-
L: 268,
|
|
236
|
-
S: this,
|
|
237
|
-
C: (f, a) => f(...a)
|
|
238
|
-
});
|
|
193
|
+
log("received request while closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 213, S: this });
|
|
239
194
|
await this._sendMessage({
|
|
240
195
|
response: {
|
|
241
196
|
id: decoded.request.id,
|
|
@@ -248,112 +203,59 @@ var RpcPeer = class {
|
|
|
248
203
|
if (req.stream) {
|
|
249
204
|
log("stream request", {
|
|
250
205
|
method: req.method
|
|
251
|
-
}, {
|
|
252
|
-
F: __dxlog_file,
|
|
253
|
-
L: 280,
|
|
254
|
-
S: this,
|
|
255
|
-
C: (f, a) => f(...a)
|
|
256
|
-
});
|
|
206
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 224, S: this });
|
|
257
207
|
this._callStreamHandler(req, (response) => {
|
|
258
|
-
log("sending stream response", {
|
|
208
|
+
log.trace("sending stream response", {
|
|
259
209
|
method: req.method,
|
|
260
210
|
response: response.payload?.type_url,
|
|
261
211
|
error: response.error,
|
|
262
212
|
close: response.close
|
|
263
|
-
}, {
|
|
264
|
-
F: __dxlog_file,
|
|
265
|
-
L: 282,
|
|
266
|
-
S: this,
|
|
267
|
-
C: (f, a) => f(...a)
|
|
268
|
-
});
|
|
213
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 228, S: this });
|
|
269
214
|
void this._sendMessage({
|
|
270
215
|
response
|
|
271
216
|
}).catch((err) => {
|
|
272
|
-
log.warn("failed during close", err, {
|
|
273
|
-
F: __dxlog_file,
|
|
274
|
-
L: 290,
|
|
275
|
-
S: this,
|
|
276
|
-
C: (f, a) => f(...a)
|
|
277
|
-
});
|
|
217
|
+
log.warn("failed during close", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 237, S: this });
|
|
278
218
|
});
|
|
279
219
|
});
|
|
280
220
|
} else {
|
|
281
|
-
DEBUG_CALLS && log("requesting...", {
|
|
221
|
+
DEBUG_CALLS && log.trace("requesting...", {
|
|
282
222
|
method: req.method
|
|
283
|
-
}, {
|
|
284
|
-
F: __dxlog_file,
|
|
285
|
-
L: 294,
|
|
286
|
-
S: this,
|
|
287
|
-
C: (f, a) => f(...a)
|
|
288
|
-
});
|
|
223
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 241, S: this });
|
|
289
224
|
const response = await this._callHandler(req);
|
|
290
|
-
DEBUG_CALLS && log("sending response", {
|
|
225
|
+
DEBUG_CALLS && log.trace("sending response", {
|
|
291
226
|
method: req.method,
|
|
292
227
|
response: response.payload?.type_url,
|
|
293
228
|
error: response.error
|
|
294
|
-
}, {
|
|
295
|
-
F: __dxlog_file,
|
|
296
|
-
L: 297,
|
|
297
|
-
S: this,
|
|
298
|
-
C: (f, a) => f(...a)
|
|
299
|
-
});
|
|
229
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 245, S: this });
|
|
300
230
|
await this._sendMessage({
|
|
301
231
|
response
|
|
302
232
|
});
|
|
303
233
|
}
|
|
304
234
|
} else if (decoded.response) {
|
|
305
235
|
if (this._state !== "OPENED") {
|
|
306
|
-
log("received response while closed", void 0, {
|
|
307
|
-
F: __dxlog_file,
|
|
308
|
-
L: 306,
|
|
309
|
-
S: this,
|
|
310
|
-
C: (f, a) => f(...a)
|
|
311
|
-
});
|
|
236
|
+
log("received response while closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 256, S: this });
|
|
312
237
|
return;
|
|
313
238
|
}
|
|
314
239
|
const responseId = decoded.response.id;
|
|
315
|
-
invariant(typeof responseId === "number", void 0, {
|
|
316
|
-
F: __dxlog_file,
|
|
317
|
-
L: 311,
|
|
318
|
-
S: this,
|
|
319
|
-
A: [
|
|
320
|
-
"typeof responseId === 'number'",
|
|
321
|
-
""
|
|
322
|
-
]
|
|
323
|
-
});
|
|
240
|
+
invariant(typeof responseId === "number", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 260, S: this, A: ["typeof responseId === 'number'", ""] });
|
|
324
241
|
if (!this._outgoingRequests.has(responseId)) {
|
|
325
|
-
log("received response with invalid id", {
|
|
242
|
+
log.trace("received response with invalid id", {
|
|
326
243
|
responseId
|
|
327
|
-
}, {
|
|
328
|
-
F: __dxlog_file,
|
|
329
|
-
L: 313,
|
|
330
|
-
S: this,
|
|
331
|
-
C: (f, a) => f(...a)
|
|
332
|
-
});
|
|
244
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 262, S: this });
|
|
333
245
|
return;
|
|
334
246
|
}
|
|
335
247
|
const item = this._outgoingRequests.get(responseId);
|
|
336
248
|
if (!item.stream) {
|
|
337
249
|
this._outgoingRequests.delete(responseId);
|
|
338
250
|
}
|
|
339
|
-
DEBUG_CALLS && log("response", {
|
|
251
|
+
DEBUG_CALLS && log.trace("response", {
|
|
340
252
|
type_url: decoded.response.payload?.type_url
|
|
341
|
-
}, {
|
|
342
|
-
F: __dxlog_file,
|
|
343
|
-
L: 323,
|
|
344
|
-
S: this,
|
|
345
|
-
C: (f, a) => f(...a)
|
|
346
|
-
});
|
|
253
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 272, S: this });
|
|
347
254
|
item.resolve(decoded.response);
|
|
348
255
|
} else if (decoded.open) {
|
|
349
256
|
log("received open message", {
|
|
350
257
|
state: this._state
|
|
351
|
-
}, {
|
|
352
|
-
F: __dxlog_file,
|
|
353
|
-
L: 326,
|
|
354
|
-
S: this,
|
|
355
|
-
C: (f, a) => f(...a)
|
|
356
|
-
});
|
|
258
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: this });
|
|
357
259
|
if (this._params.noHandshake) {
|
|
358
260
|
return;
|
|
359
261
|
}
|
|
@@ -363,12 +265,7 @@ var RpcPeer = class {
|
|
|
363
265
|
} else if (decoded.openAck) {
|
|
364
266
|
log("received openAck message", {
|
|
365
267
|
state: this._state
|
|
366
|
-
}, {
|
|
367
|
-
F: __dxlog_file,
|
|
368
|
-
L: 333,
|
|
369
|
-
S: this,
|
|
370
|
-
C: (f, a) => f(...a)
|
|
371
|
-
});
|
|
268
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 287, S: this });
|
|
372
269
|
if (this._params.noHandshake) {
|
|
373
270
|
return;
|
|
374
271
|
}
|
|
@@ -376,41 +273,18 @@ var RpcPeer = class {
|
|
|
376
273
|
this._remoteOpenTrigger.wake();
|
|
377
274
|
} else if (decoded.streamClose) {
|
|
378
275
|
if (this._state !== "OPENED") {
|
|
379
|
-
log("received stream close while closed", void 0, {
|
|
380
|
-
F: __dxlog_file,
|
|
381
|
-
L: 342,
|
|
382
|
-
S: this,
|
|
383
|
-
C: (f, a) => f(...a)
|
|
384
|
-
});
|
|
276
|
+
log("received stream close while closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 297, S: this });
|
|
385
277
|
return;
|
|
386
278
|
}
|
|
387
279
|
log("received stream close", {
|
|
388
280
|
id: decoded.streamClose.id
|
|
389
|
-
}, {
|
|
390
|
-
|
|
391
|
-
L: 346,
|
|
392
|
-
S: this,
|
|
393
|
-
C: (f, a) => f(...a)
|
|
394
|
-
});
|
|
395
|
-
invariant(typeof decoded.streamClose.id === "number", void 0, {
|
|
396
|
-
F: __dxlog_file,
|
|
397
|
-
L: 347,
|
|
398
|
-
S: this,
|
|
399
|
-
A: [
|
|
400
|
-
"typeof decoded.streamClose.id === 'number'",
|
|
401
|
-
""
|
|
402
|
-
]
|
|
403
|
-
});
|
|
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'", ""] });
|
|
404
283
|
const stream = this._localStreams.get(decoded.streamClose.id);
|
|
405
284
|
if (!stream) {
|
|
406
285
|
log("no local stream", {
|
|
407
286
|
id: decoded.streamClose.id
|
|
408
|
-
}, {
|
|
409
|
-
F: __dxlog_file,
|
|
410
|
-
L: 350,
|
|
411
|
-
S: this,
|
|
412
|
-
C: (f, a) => f(...a)
|
|
413
|
-
});
|
|
287
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 306, S: this });
|
|
414
288
|
return;
|
|
415
289
|
}
|
|
416
290
|
this._localStreams.delete(decoded.streamClose.id);
|
|
@@ -418,12 +292,7 @@ var RpcPeer = class {
|
|
|
418
292
|
} else if (decoded.bye) {
|
|
419
293
|
this._byeTrigger.wake();
|
|
420
294
|
if (this._state !== "CLOSING" && this._state !== "CLOSED") {
|
|
421
|
-
log("replying to bye", void 0, {
|
|
422
|
-
F: __dxlog_file,
|
|
423
|
-
L: 360,
|
|
424
|
-
S: this,
|
|
425
|
-
C: (f, a) => f(...a)
|
|
426
|
-
});
|
|
295
|
+
log("replying to bye", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 317, S: this });
|
|
427
296
|
this._state = "CLOSING";
|
|
428
297
|
await this._sendMessage({
|
|
429
298
|
bye: {}
|
|
@@ -434,12 +303,7 @@ var RpcPeer = class {
|
|
|
434
303
|
} else {
|
|
435
304
|
log.error("received malformed message", {
|
|
436
305
|
msg
|
|
437
|
-
}, {
|
|
438
|
-
F: __dxlog_file,
|
|
439
|
-
L: 368,
|
|
440
|
-
S: this,
|
|
441
|
-
C: (f, a) => f(...a)
|
|
442
|
-
});
|
|
306
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 326, S: this });
|
|
443
307
|
throw new Error("Malformed message.");
|
|
444
308
|
}
|
|
445
309
|
}
|
|
@@ -448,14 +312,9 @@ var RpcPeer = class {
|
|
|
448
312
|
* Peer should be open before making this call.
|
|
449
313
|
*/
|
|
450
314
|
async call(method, request, options) {
|
|
451
|
-
DEBUG_CALLS && log("calling...", {
|
|
315
|
+
DEBUG_CALLS && log.trace("calling...", {
|
|
452
316
|
method
|
|
453
|
-
}, {
|
|
454
|
-
F: __dxlog_file,
|
|
455
|
-
L: 378,
|
|
456
|
-
S: this,
|
|
457
|
-
C: (f, a) => f(...a)
|
|
458
|
-
});
|
|
317
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 336, S: this });
|
|
459
318
|
throwIfNotOpen(this._state);
|
|
460
319
|
let response;
|
|
461
320
|
try {
|
|
@@ -469,12 +328,7 @@ var RpcPeer = class {
|
|
|
469
328
|
} catch (err) {
|
|
470
329
|
log.warn("failed to encode trace context", {
|
|
471
330
|
err
|
|
472
|
-
}, {
|
|
473
|
-
F: __dxlog_file,
|
|
474
|
-
L: 393,
|
|
475
|
-
S: this,
|
|
476
|
-
C: (f, a) => f(...a)
|
|
477
|
-
});
|
|
331
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 351, S: this });
|
|
478
332
|
}
|
|
479
333
|
const sending = this._sendMessage({
|
|
480
334
|
request: {
|
|
@@ -494,15 +348,7 @@ var RpcPeer = class {
|
|
|
494
348
|
waiting
|
|
495
349
|
]);
|
|
496
350
|
response = await waiting;
|
|
497
|
-
invariant(response.id === id, void 0, {
|
|
498
|
-
F: __dxlog_file,
|
|
499
|
-
L: 414,
|
|
500
|
-
S: this,
|
|
501
|
-
A: [
|
|
502
|
-
"response.id === id",
|
|
503
|
-
""
|
|
504
|
-
]
|
|
505
|
-
});
|
|
351
|
+
invariant(response.id === id, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 375, S: this, A: ["response.id === id", ""] });
|
|
506
352
|
} catch (err) {
|
|
507
353
|
if (err instanceof RpcClosedError) {
|
|
508
354
|
const error = new RpcClosedError();
|
|
@@ -563,12 +409,7 @@ ${stack.getStack()}`;
|
|
|
563
409
|
} catch (err) {
|
|
564
410
|
log.warn("failed to encode trace context", {
|
|
565
411
|
err
|
|
566
|
-
}, {
|
|
567
|
-
F: __dxlog_file,
|
|
568
|
-
L: 476,
|
|
569
|
-
S: this,
|
|
570
|
-
C: (f, a) => f(...a)
|
|
571
|
-
});
|
|
412
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 429, S: this });
|
|
572
413
|
}
|
|
573
414
|
try {
|
|
574
415
|
this._sendMessage({
|
|
@@ -595,26 +436,16 @@ ${stack.getStack()}`;
|
|
|
595
436
|
id
|
|
596
437
|
}
|
|
597
438
|
}).catch((err) => {
|
|
598
|
-
log.catch(err, void 0, {
|
|
599
|
-
F: __dxlog_file,
|
|
600
|
-
L: 501,
|
|
601
|
-
S: this,
|
|
602
|
-
C: (f, a) => f(...a)
|
|
603
|
-
});
|
|
439
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 458, S: this });
|
|
604
440
|
});
|
|
605
441
|
this._outgoingRequests.delete(id);
|
|
606
442
|
};
|
|
607
443
|
});
|
|
608
444
|
}
|
|
609
445
|
async _sendMessage(message, timeout) {
|
|
610
|
-
DEBUG_CALLS && log("sending message", {
|
|
446
|
+
DEBUG_CALLS && log.trace("sending message", {
|
|
611
447
|
type: Object.keys(message)[0]
|
|
612
|
-
}, {
|
|
613
|
-
F: __dxlog_file,
|
|
614
|
-
L: 509,
|
|
615
|
-
S: this,
|
|
616
|
-
C: (f, a) => f(...a)
|
|
617
|
-
});
|
|
448
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 465, S: this });
|
|
618
449
|
await this._params.port.send(getRpcMessageCodec().encode(message, {
|
|
619
450
|
preserveAny: true
|
|
620
451
|
}), timeout);
|
|
@@ -628,12 +459,7 @@ ${stack.getStack()}`;
|
|
|
628
459
|
log.warn("failed to decode trace context", {
|
|
629
460
|
traceContext: req.traceContext,
|
|
630
461
|
err
|
|
631
|
-
}, {
|
|
632
|
-
F: __dxlog_file,
|
|
633
|
-
L: 519,
|
|
634
|
-
S: this,
|
|
635
|
-
C: (f, a) => f(...a)
|
|
636
|
-
});
|
|
462
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 478, S: this });
|
|
637
463
|
}
|
|
638
464
|
}
|
|
639
465
|
if (!traceCtx && !this._params.handlerRpcOptions) {
|
|
@@ -648,33 +474,9 @@ ${stack.getStack()}`;
|
|
|
648
474
|
}
|
|
649
475
|
async _callHandler(req) {
|
|
650
476
|
try {
|
|
651
|
-
invariant(typeof req.id === "number", void 0, {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
S: this,
|
|
655
|
-
A: [
|
|
656
|
-
"typeof req.id === 'number'",
|
|
657
|
-
""
|
|
658
|
-
]
|
|
659
|
-
});
|
|
660
|
-
invariant(req.payload, void 0, {
|
|
661
|
-
F: __dxlog_file,
|
|
662
|
-
L: 531,
|
|
663
|
-
S: this,
|
|
664
|
-
A: [
|
|
665
|
-
"req.payload",
|
|
666
|
-
""
|
|
667
|
-
]
|
|
668
|
-
});
|
|
669
|
-
invariant(req.method, void 0, {
|
|
670
|
-
F: __dxlog_file,
|
|
671
|
-
L: 532,
|
|
672
|
-
S: this,
|
|
673
|
-
A: [
|
|
674
|
-
"req.method",
|
|
675
|
-
""
|
|
676
|
-
]
|
|
677
|
-
});
|
|
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", ""] });
|
|
678
480
|
const response = await this._params.callHandler(req.method, req.payload, this._getHandlerRpcOptions(req));
|
|
679
481
|
return {
|
|
680
482
|
id: req.id,
|
|
@@ -689,42 +491,10 @@ ${stack.getStack()}`;
|
|
|
689
491
|
}
|
|
690
492
|
_callStreamHandler(req, callback) {
|
|
691
493
|
try {
|
|
692
|
-
invariant(this._params.streamHandler, "Requests with streaming responses are not supported.", {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
A: [
|
|
697
|
-
"this._params.streamHandler",
|
|
698
|
-
"'Requests with streaming responses are not supported.'"
|
|
699
|
-
]
|
|
700
|
-
});
|
|
701
|
-
invariant(typeof req.id === "number", void 0, {
|
|
702
|
-
F: __dxlog_file,
|
|
703
|
-
L: 550,
|
|
704
|
-
S: this,
|
|
705
|
-
A: [
|
|
706
|
-
"typeof req.id === 'number'",
|
|
707
|
-
""
|
|
708
|
-
]
|
|
709
|
-
});
|
|
710
|
-
invariant(req.payload, void 0, {
|
|
711
|
-
F: __dxlog_file,
|
|
712
|
-
L: 551,
|
|
713
|
-
S: this,
|
|
714
|
-
A: [
|
|
715
|
-
"req.payload",
|
|
716
|
-
""
|
|
717
|
-
]
|
|
718
|
-
});
|
|
719
|
-
invariant(req.method, void 0, {
|
|
720
|
-
F: __dxlog_file,
|
|
721
|
-
L: 552,
|
|
722
|
-
S: this,
|
|
723
|
-
A: [
|
|
724
|
-
"req.method",
|
|
725
|
-
""
|
|
726
|
-
]
|
|
727
|
-
});
|
|
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", ""] });
|
|
728
498
|
const responseStream = this._params.streamHandler(req.method, req.payload, this._getHandlerRpcOptions(req));
|
|
729
499
|
responseStream.onReady(() => {
|
|
730
500
|
callback({
|
|
@@ -800,15 +570,7 @@ var ProtoRpcPeer = class {
|
|
|
800
570
|
var createProtoRpcPeer = ({ requested, exposed, handlers, encodingOptions, ...rest }) => {
|
|
801
571
|
const exposedRpcs = {};
|
|
802
572
|
if (exposed) {
|
|
803
|
-
invariant2(handlers, void 0, {
|
|
804
|
-
F: __dxlog_file2,
|
|
805
|
-
L: 93,
|
|
806
|
-
S: void 0,
|
|
807
|
-
A: [
|
|
808
|
-
"handlers",
|
|
809
|
-
""
|
|
810
|
-
]
|
|
811
|
-
});
|
|
573
|
+
invariant2(handlers, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0, A: ["handlers", ""] });
|
|
812
574
|
for (const serviceName of Object.keys(exposed)) {
|
|
813
575
|
const serviceFqn = exposed[serviceName].serviceProto.fullName.slice(1);
|
|
814
576
|
const serviceProvider = handlers[serviceName];
|