socket-function 0.84.0 → 0.86.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.84.0",
3
+ "version": "0.86.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -92,7 +92,7 @@ export function requireMain() {
92
92
  // Globals
93
93
  Object.assign(window, {
94
94
  process: {
95
- argv: [],
95
+ argv: window?.process?.argv || [],
96
96
  env: {
97
97
  // Mirror the tnode.js setting
98
98
  NODE_ENV: "production",
@@ -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);