@electric-sql/client 1.5.5 → 1.5.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.
@@ -609,6 +609,12 @@ function createFetchWithChunkBuffer(fetchClient, prefetchOptions = ChunkPrefetch
609
609
  let prefetchQueue;
610
610
  const prefetchClient = async (...args) => {
611
611
  const url = args[0].toString();
612
+ const method = getRequestMethod(args[0], args[1]);
613
+ if (method !== `GET`) {
614
+ prefetchQueue == null ? void 0 : prefetchQueue.abort();
615
+ prefetchQueue = void 0;
616
+ return fetchClient(...args);
617
+ }
612
618
  const prefetchedRequest = prefetchQueue == null ? void 0 : prefetchQueue.consume(...args);
613
619
  if (prefetchedRequest) {
614
620
  return prefetchedRequest;
@@ -778,6 +784,15 @@ function chainAborter(aborter, sourceSignal) {
778
784
  }
779
785
  function noop() {
780
786
  }
787
+ function getRequestMethod(input, init) {
788
+ if (init == null ? void 0 : init.method) {
789
+ return init.method.toUpperCase();
790
+ }
791
+ if (typeof Request !== `undefined` && input instanceof Request) {
792
+ return input.method.toUpperCase();
793
+ }
794
+ return `GET`;
795
+ }
781
796
 
782
797
  // src/expression-compiler.ts
783
798
  function compileExpression(expr, columnMapper) {
@@ -1454,6 +1469,12 @@ var FetchingState = class extends ActiveState {
1454
1469
  const staleResult = this.checkStaleResponse(input);
1455
1470
  if (staleResult) return staleResult;
1456
1471
  const shared = this.parseResponseFields(input);
1472
+ if (input.status === 204) {
1473
+ return {
1474
+ action: `accepted`,
1475
+ state: new LiveState(shared, { sseFallbackToLongPolling: true })
1476
+ };
1477
+ }
1457
1478
  return { action: `accepted`, state: new SyncingState(shared) };
1458
1479
  }
1459
1480
  canEnterReplayMode() {
@@ -2602,7 +2623,9 @@ requestShapeSSE_fn = async function(opts) {
2602
2623
  if (requestAbortController.signal.aborted) {
2603
2624
  throw new FetchBackoffAbortError();
2604
2625
  }
2605
- throw error;
2626
+ if (error instanceof FetchError || error instanceof StaleCacheError || error instanceof MissingHeadersError) {
2627
+ throw error;
2628
+ }
2606
2629
  } finally {
2607
2630
  const connectionDuration = Date.now() - __privateGet(this, _lastSseConnectionStartTime);
2608
2631
  const wasAborted = requestAbortController.signal.aborted;