@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/index.legacy-esm.js
CHANGED
|
@@ -733,6 +733,13 @@ function getNextChunkUrl(url, res) {
|
|
|
733
733
|
if (!shapeHandle || !lastOffset || isUpToDate) return;
|
|
734
734
|
const nextUrl = new URL(url);
|
|
735
735
|
if (nextUrl.searchParams.has(LIVE_QUERY_PARAM)) return;
|
|
736
|
+
const expiredHandle = nextUrl.searchParams.get(EXPIRED_HANDLE_QUERY_PARAM);
|
|
737
|
+
if (expiredHandle && shapeHandle === expiredHandle) {
|
|
738
|
+
console.warn(
|
|
739
|
+
`[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.`
|
|
740
|
+
);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
736
743
|
nextUrl.searchParams.set(SHAPE_HANDLE_QUERY_PARAM, shapeHandle);
|
|
737
744
|
nextUrl.searchParams.set(OFFSET_QUERY_PARAM, lastOffset);
|
|
738
745
|
nextUrl.searchParams.sort();
|
|
@@ -1541,7 +1548,15 @@ onInitialResponse_fn = async function(response) {
|
|
|
1541
1548
|
const { headers, status } = response;
|
|
1542
1549
|
const shapeHandle = headers.get(SHAPE_HANDLE_HEADER);
|
|
1543
1550
|
if (shapeHandle) {
|
|
1544
|
-
|
|
1551
|
+
const shapeKey = __privateGet(this, _currentFetchUrl) ? canonicalShapeKey(__privateGet(this, _currentFetchUrl)) : null;
|
|
1552
|
+
const expiredHandle = shapeKey ? expiredShapesCache.getExpiredHandle(shapeKey) : null;
|
|
1553
|
+
if (shapeHandle !== expiredHandle) {
|
|
1554
|
+
__privateSet(this, _shapeHandle, shapeHandle);
|
|
1555
|
+
} else {
|
|
1556
|
+
console.warn(
|
|
1557
|
+
`[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)}".`
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1545
1560
|
}
|
|
1546
1561
|
const lastOffset = headers.get(CHUNK_LAST_OFFSET_HEADER);
|
|
1547
1562
|
if (lastOffset) {
|