socket-function 0.85.0 → 0.87.0

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/SocketFunction.ts CHANGED
@@ -244,6 +244,9 @@ export class SocketFunction {
244
244
  let callFactory = await getCreateCallFactory(nodeId);
245
245
 
246
246
  let shapeObj = shape?.[functionName];
247
+ if (!shapeObj) {
248
+ shapeObj = {};
249
+ }
247
250
  // NOTE: Actually... this just means the client doesn't have a definition for it. The server
248
251
  // might, so call it, and let them throw if it is unrecognized.
249
252
  // if (!shapeObj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.85.0",
3
+ "version": "0.87.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -155,18 +155,22 @@ export async function createCallFactory(
155
155
  functionName: call.functionName,
156
156
  seqNum,
157
157
  };
158
+ let data: Buffer[];
158
159
  let originalArgs = call.args;
159
- if (shouldCompressCall(fullCall)) {
160
- fullCall.args = await compressObj(fullCall.args) as any;
161
- fullCall.isArgsCompressed = true;
162
- }
163
160
  let time = Date.now();
164
- let data: Buffer[];
165
- let dataMaybePromise = SocketFunction.WIRE_SERIALIZER.serialize(fullCall);
166
- if (dataMaybePromise instanceof Promise) {
167
- data = await dataMaybePromise;
168
- } else {
169
- data = dataMaybePromise;
161
+ try {
162
+ if (shouldCompressCall(fullCall)) {
163
+ fullCall.args = await compressObj(fullCall.args) as any;
164
+ fullCall.isArgsCompressed = true;
165
+ }
166
+ let dataMaybePromise = SocketFunction.WIRE_SERIALIZER.serialize(fullCall);
167
+ if (dataMaybePromise instanceof Promise) {
168
+ data = await dataMaybePromise;
169
+ } else {
170
+ data = dataMaybePromise;
171
+ }
172
+ } catch (e: any) {
173
+ throw new Error(`Error serializing data for call ${call.classGuid}.${call.functionName}\n${e.stack}`);
170
174
  }
171
175
  time = Date.now() - time;
172
176
  let size = data.map(x => x.length).reduce((a, b) => a + b, 0);
package/src/nodeProxy.ts CHANGED
@@ -20,6 +20,10 @@ export function getCallProxy(id: string, callback: (callType: FullCallType) => P
20
20
  nodeProxy = new Proxy(Object.create(null), {
21
21
  get(target, functionName) {
22
22
  if (typeof functionName !== "string") return undefined;
23
+ // Ignore "then" calls, as they happen when awaiting a callProxy (to check if it's
24
+ // a promise), and we don't want to act like a promise (we don't want to call the
25
+ // "then" api call).
26
+ if (functionName === "then") return undefined;
23
27
  return Object.assign(
24
28
  (...args: unknown[]) => {
25
29
  let call: FullCallType = {