@electric-sql/client 1.3.0 → 1.3.1
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/cjs/index.cjs +16 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.legacy-esm.js +16 -1
- package/dist/index.legacy-esm.js.map +1 -1
- package/dist/index.mjs +16 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +20 -1
- package/src/fetch.ts +16 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -768,6 +768,13 @@ function getNextChunkUrl(url, res) {
|
|
|
768
768
|
if (!shapeHandle || !lastOffset || isUpToDate) return;
|
|
769
769
|
const nextUrl = new URL(url);
|
|
770
770
|
if (nextUrl.searchParams.has(LIVE_QUERY_PARAM)) return;
|
|
771
|
+
const expiredHandle = nextUrl.searchParams.get(EXPIRED_HANDLE_QUERY_PARAM);
|
|
772
|
+
if (expiredHandle && shapeHandle === expiredHandle) {
|
|
773
|
+
console.warn(
|
|
774
|
+
`[Electric] Received stale cached response with expired shape handle. This should not happen and indicates a proxy/CDN caching misconfiguration. The response contained handle "${shapeHandle}" which was previously marked as expired. Check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key. Skipping prefetch to prevent infinite 409 loop.`
|
|
775
|
+
);
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
771
778
|
nextUrl.searchParams.set(SHAPE_HANDLE_QUERY_PARAM, shapeHandle);
|
|
772
779
|
nextUrl.searchParams.set(OFFSET_QUERY_PARAM, lastOffset);
|
|
773
780
|
nextUrl.searchParams.sort();
|
|
@@ -1574,7 +1581,15 @@ onInitialResponse_fn = async function(response) {
|
|
|
1574
1581
|
const { headers, status } = response;
|
|
1575
1582
|
const shapeHandle = headers.get(SHAPE_HANDLE_HEADER);
|
|
1576
1583
|
if (shapeHandle) {
|
|
1577
|
-
|
|
1584
|
+
const shapeKey = __privateGet(this, _currentFetchUrl) ? canonicalShapeKey(__privateGet(this, _currentFetchUrl)) : null;
|
|
1585
|
+
const expiredHandle = shapeKey ? expiredShapesCache.getExpiredHandle(shapeKey) : null;
|
|
1586
|
+
if (shapeHandle !== expiredHandle) {
|
|
1587
|
+
__privateSet(this, _shapeHandle, shapeHandle);
|
|
1588
|
+
} else {
|
|
1589
|
+
console.warn(
|
|
1590
|
+
`[Electric] Received stale cached response with expired shape handle. This should not happen and indicates a proxy/CDN caching misconfiguration. The response contained handle "${shapeHandle}" which was previously marked as expired. Check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key. Ignoring the stale handle and continuing with handle "${__privateGet(this, _shapeHandle)}".`
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1578
1593
|
}
|
|
1579
1594
|
const lastOffset = headers.get(CHUNK_LAST_OFFSET_HEADER);
|
|
1580
1595
|
if (lastOffset) {
|