@igoforth/ws-rpc 1.1.4 → 1.1.5

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.
@@ -3,6 +3,7 @@ import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
4
  import "../protocol-C5QIKXey.js";
5
5
  import "../errors-C5IC-13X.js";
6
+ import { t as MemoryPendingCallStorage } from "../memory-Bqb3KEVr.js";
6
7
  import { t as SqlPendingCallStorage } from "../sql-CCjc6Bid.js";
7
8
  import "../default-DwjN80sT.js";
8
9
  import { n as createDurableRpcPeerFactory } from "../durable-BIdilnMO.js";
@@ -132,14 +133,19 @@ function withRpc(Base, options) {
132
133
  *
133
134
  * Handles peer management, message routing, and durable storage.
134
135
  * Uses SQL storage from the Durable Object for hibernation-safe calls.
135
- *
136
- * @throws Error if DurableObjectStorage is not available
136
+ * Falls back to in-memory storage if DurableObjectStorage is not available.
137
137
  */
138
138
  get _rpc() {
139
- if (!this.storage.raw) throw new Error("DurableObjectStorage not present in actor `raw`");
140
- return this.__rpc ??= new DOMultiPeer({
139
+ if (this.__rpc) return this.__rpc;
140
+ let storage;
141
+ if (this.storage?.raw) storage = new SqlPendingCallStorage(this.storage.raw.sql);
142
+ else {
143
+ console.warn(`[ws-rpc] DurableObjectStorage not available (storage=${typeof this.storage}, this=${this?.constructor?.name ?? typeof this}). Falling back to in-memory storage. Pending calls will not survive hibernation.`);
144
+ storage = new MemoryPendingCallStorage();
145
+ }
146
+ return this.__rpc = new DOMultiPeer({
141
147
  actor: this,
142
- storage: new SqlPendingCallStorage(this.storage.raw.sql),
148
+ storage,
143
149
  localSchema: options.localSchema,
144
150
  remoteSchema: options.remoteSchema,
145
151
  provider: this,
@@ -3,6 +3,7 @@ import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
4
  import "../protocol-C5QIKXey.js";
5
5
  import "../errors-C5IC-13X.js";
6
+ import "../memory-Bqb3KEVr.js";
6
7
  import "../sql-CCjc6Bid.js";
7
8
  import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-Cdr_3mjN.js";
8
9
  import "../default-DwjN80sT.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igoforth/ws-rpc",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Bidirectional RPC over WebSocket with Zod schema validation, TypeScript inference, and Cloudflare Durable Object support",
5
5
  "type": "module",
6
6
  "license": "MIT",