nucleus-core-ts 0.9.976 → 0.9.977

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/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.9.976
1
+ 0.9.977
@@ -244,6 +244,22 @@ export function createWsProxyHandler(config) {
244
244
  rejectUnauthorized: state.rejectUnauthorized
245
245
  }
246
246
  });
247
+ /*
248
+ * Ask for ArrayBuffer, because the default is not one.
249
+ *
250
+ * Bun's client WebSocket defaults `binaryType` to `'nodebuffer'`, so a
251
+ * binary frame arrives as a Node `Buffer`. A Buffer is neither an
252
+ * `ArrayBuffer` nor a `Blob`, so it matched none of the branches below
253
+ * and was silently discarded — a proxy that relays text perfectly and
254
+ * drops every binary frame without a word.
255
+ *
256
+ * Measured against a Next 16 dev server, which sends its React debug
257
+ * chunks as binary on the HMR socket: 5 frames direct, 2 of them
258
+ * binary; 3 frames through the proxy, 0 binary. The consequence was a
259
+ * page that never hydrated at all — the client awaits those chunks
260
+ * before calling `hydrateRoot`, so the whole app stayed as the server
261
+ * had sent it, blank.
262
+ */ backendWs.binaryType = 'arraybuffer';
247
263
  backendWs.onopen = ()=>{
248
264
  logger.info(`Backend connected: ${state.path}`);
249
265
  config.onOpen?.(state.path, state.target);
@@ -266,10 +282,22 @@ export function createWsProxyHandler(config) {
266
282
  ws.send(event.data);
267
283
  } else if (event.data instanceof ArrayBuffer) {
268
284
  ws.send(new Uint8Array(event.data));
285
+ } else if (ArrayBuffer.isView(event.data)) {
286
+ // A Buffer, a Uint8Array, a DataView — anything with a backing
287
+ // buffer. Kept even though `binaryType` is now set, because the
288
+ // silent-drop is the failure mode to design against: a runtime
289
+ // whose default differs would lose frames here with nothing in any
290
+ // log to say so.
291
+ const view = event.data;
292
+ ws.send(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
269
293
  } else if (event.data instanceof Blob) {
270
294
  event.data.arrayBuffer().then((buffer)=>{
271
295
  ws.send(new Uint8Array(buffer));
272
296
  });
297
+ } else {
298
+ // Never silently. If a frame cannot be relayed, that is a fact
299
+ // somebody has to be able to find.
300
+ logger.warn(`Dropped an unrelayable frame on ${state.path}: ${Object.prototype.toString.call(event.data)}`);
273
301
  }
274
302
  };
275
303
  backendWs.onerror = (event)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.9.976",
3
+ "version": "0.9.977",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",