Skip to content

Commit

Permalink
Revert "sync lock"
Browse files Browse the repository at this point in the history
This reverts commit f1521b5.
  • Loading branch information
tantaman committed Dec 8, 2023
1 parent d7590d4 commit a5ab825
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 630 deletions.
4 changes: 1 addition & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"clean": "rm -rf ./dist; mkdir -p ./dist",
"prod": "cp -r ./dist/ ../server/dist/; cd ../server; npm run prod",
"server": "cd ../server && npm run dev",
"test": "vitest",
"watch": "concurrently --kill-others 'npm run server' 'npm run check-types -- --watch --preserveWatchOutput' 'sleep 3; npm run dev'"
},
"dependencies": {
Expand Down Expand Up @@ -58,8 +57,7 @@
"typescript": "^4.7.4",
"use-debounce": "^9.0.4",
"vite": "^3.0.7",
"vite-plugin-svgr": "^4.1.0",
"vitest": "^1.0.1"
"vite-plugin-svgr": "^4.1.0"
},
"eslintConfig": {
"extends": "@rocicorp/eslint-config"
Expand Down
32 changes: 0 additions & 32 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {mutators} from './model/mutators';
import {Replicache} from 'replicache';
import {UndoManager} from '@rocicorp/undo';
import App from './app';
import {lock} from './util/sync-lock';

async function init() {
// See https://doc.replicache.dev/licensing for how to get a license key.
Expand All @@ -13,34 +12,11 @@ async function init() {
throw new Error('Missing VITE_REPLICACHE_LICENSE_KEY');
}

const syncLock = lock('pull');
const r = new Replicache({
name: 'anon',
licenseKey,
mutators,
logLevel: 'debug',
puller: async requestBody => {
if (!syncLock.held) {
return {
httpRequestInfo: {
errorMessage: 'Tab does not hold the pull lock',
httpStatusCode: 400,
},
};
}
const res = await fetch('/api/replicache/pull', {
method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify(requestBody),
});
return {
response: await res.json(),
httpRequestInfo: {
errorMessage: !res.ok ? res.statusText : '',
httpStatusCode: res.status,
},
};
},
pushURL: `/api/replicache/push`,
pullURL: `/api/replicache/pull`,
});
Expand All @@ -57,14 +33,6 @@ async function init() {
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<Root />,
);

// Issue a pull whenever we become leader.
syncLock.onStatusChange(async held => {
if (held) {
console.log('status change?');
await r.pull();
}
});
}

await init();
211 changes: 0 additions & 211 deletions client/src/util/__tests__/snyc-lock.test.ts

This file was deleted.

Loading

0 comments on commit a5ab825

Please sign in to comment.