iii-browser-sdk 0.25.0-rc.5 → 0.25.0-rc.6

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/dist/index.cjs CHANGED
@@ -805,7 +805,11 @@ const MATCH_ALL = compileFilter({});
805
805
  */
806
806
  const FEATURE_OBSERVE_V1 = "observe.v1";
807
807
  const FEATURE_LOCAL_DISPATCH_V1 = "local-dispatch.v1";
808
- /** What this SDK declares in `engine::workers::register`. */
808
+ /**
809
+ * What this SDK declares in `engine::workers::register`. Not
810
+ * `large-messages.v1`, unlike the other SDKs: a browser receives one 16 MiB
811
+ * WebSocket frame at most.
812
+ */
809
813
  const SDK_FEATURES = [FEATURE_OBSERVE_V1, FEATURE_LOCAL_DISPATCH_V1];
810
814
 
811
815
  //#endregion
@@ -2234,10 +2238,13 @@ function buildLocalInvocationStats(windowMs, stats, drops) {
2234
2238
  const MAX_JSON_FRAME_BYTES = 16 * 1024 * 1024;
2235
2239
  const JSON_ENCODER = new TextEncoder();
2236
2240
  const PAYLOAD_SIZE_DOCS = "https://iii.dev/docs/creating-workers/channels#payload-size";
2241
+ function payloadTooLargeMessage(size) {
2242
+ return `Serialized JSON envelope is ${size} bytes; limit is ${MAX_JSON_FRAME_BYTES} bytes. Use channels for larger payloads: ${PAYLOAD_SIZE_DOCS}`;
2243
+ }
2237
2244
  function createPayloadTooLargeError(size, functionId) {
2238
2245
  return new InvocationError({
2239
2246
  code: "payload_too_large",
2240
- message: `Serialized JSON envelope is ${size} bytes; limit is ${MAX_JSON_FRAME_BYTES} bytes. Use channels for larger payloads: ${PAYLOAD_SIZE_DOCS}`,
2247
+ message: payloadTooLargeMessage(size),
2241
2248
  function_id: functionId
2242
2249
  });
2243
2250
  }
@@ -3025,7 +3032,7 @@ var Sdk = class {
3025
3032
  function_id: message.function_id,
3026
3033
  error: {
3027
3034
  code: error.code,
3028
- message: error.message
3035
+ message: payloadTooLargeMessage(size)
3029
3036
  }
3030
3037
  });
3031
3038
  if (JSON_ENCODER.encode(fallback).byteLength <= MAX_JSON_FRAME_BYTES) return fallback;