Skip to content

Commit b4c958f

Browse files
committed
Patch @powersync/common 1.53.0 with injectable race fix
Backports powersync-ja/powersync-js#960. Without it, ~1 in 3 local writes triggers a checksum mismatch and a full bucket wipe (see #954). patch-package applies the diff on every install so CI ships it too; remove once a release with the upstream fix is published.
1 parent 2f0f08c commit b4c958f

3 files changed

Lines changed: 317 additions & 4 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"lint": "eslint .",
1414
"deploy": "netlify deploy --prod -s knowledge-medium-explorations.netlify.app -d dist",
1515
"preview": "vite preview",
16+
"postinstall": "patch-package",
1617
"test": "vitest run",
1718
"test:watch": "vitest",
1819
"test:coverage": "vitest run --coverage",
@@ -89,6 +90,7 @@
8990
"eslint-plugin-react-refresh": "^0.5.2",
9091
"globals": "^17.5.0",
9192
"jsdom": "^29.1.0",
93+
"patch-package": "^8.0.1",
9294
"pg": "^8.20.0",
9395
"playwright": "^1.59.1",
9496
"postcss": "^8.5.12",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/node_modules/@powersync/common/dist/bundle.mjs b/node_modules/@powersync/common/dist/bundle.mjs
2+
index 67d355f..3da5e67 100644
3+
--- a/node_modules/@powersync/common/dist/bundle.mjs
4+
+++ b/node_modules/@powersync/common/dist/bundle.mjs
5+
@@ -10837,6 +10837,7 @@ function injectable(source) {
6+
let waiter = undefined; // An active, waiting next() call.
7+
// A pending upstream event that couldn't be dispatched because inject() has been called before it was resolved.
8+
let pendingSourceEvent = null;
9+
+ let sourceFetchInFlight = false;
10+
let pendingInjectedEvents = [];
11+
const consumeWaiter = () => {
12+
const pending = waiter;
13+
@@ -10845,6 +10846,7 @@ function injectable(source) {
14+
};
15+
const fetchFromSource = () => {
16+
const resolveWaiter = (propagate) => {
17+
+ sourceFetchInFlight = false;
18+
const active = consumeWaiter();
19+
if (active) {
20+
propagate(active);
21+
@@ -10853,6 +10855,7 @@ function injectable(source) {
22+
pendingSourceEvent = propagate;
23+
}
24+
};
25+
+ sourceFetchInFlight = true;
26+
const nextFromSource = source.next();
27+
nextFromSource.then((value) => {
28+
sourceIsDone = value.done == true;
29+
@@ -10879,7 +10882,9 @@ function injectable(source) {
30+
}
31+
// Nothing pending? Fetch from source
32+
waiter = { resolve, reject };
33+
- return fetchFromSource();
34+
+ if (!sourceFetchInFlight) {
35+
+ fetchFromSource();
36+
+ }
37+
});
38+
},
39+
inject: (event) => {

0 commit comments

Comments
 (0)