Skip to content

Commit 888a9ce

Browse files
committed
fixed async queue swallowing errors
1 parent e02cef3 commit 888a9ce

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ If you are interested in using or contributing to SQLSync, please [join the Disc
3737

3838
Please refer to [the guide](./GUIDE.md) to learn how to add SQLSync to your application.
3939

40+
## Tips & Tricks
41+
42+
### How to debug SQLSync in the browser
43+
By default SQLSync runs in a shared web worker. This allows the database to automatically be shared between different tabs, however results in making SQLSync a bit harder to debug.
44+
45+
The easiest way is to use Google Chrome, and go to the special URL: [chrome://inspect/#workers](chrome://inspect/#workers). On that page you'll find a list of all the running shared workers in other tabs. Assuming another tab is running SQLSync, you'll see the shared worker listed. Click `inspect` to open up dev-tools for the worker.
46+
4047
## Community & Contributing
4148

4249
If you are interested in contributing to SQLSync, please [join the Discord community][discord] and let us know what you want to build. All contributions will be held to a high standard, and are more likely to be accepted if they are tied to an existing task and agreed upon specification.

lib/sqlsync-worker/sqlsync-wasm/src/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ pub async fn fetch_reducer(reducer_url: &str) -> Result<(WasmReducer, Vec<u8>),
137137
Uint8Array::new(&digest).to_vec()
138138
};
139139

140-
let reducer = WasmReducer::new(reducer_wasm_bytes.as_slice())?;
140+
let reducer = WasmReducer::new(reducer_wasm_bytes.as_slice())
141+
.map_err(|err| anyhow!("failed to instantiate reducer from wasm: {}", err))?;
141142

142143
Ok((reducer, digest))
143144
}

lib/sqlsync-worker/src/worker.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ const MessageQueue = (() => {
1919
let queue = Promise.resolve();
2020
return {
2121
push: (m: Message) => {
22-
queue = queue.then(
23-
() => handleMessage(m),
24-
(e) => {
22+
queue = queue.then(async () => {
23+
try {
24+
await handleMessage(m);
25+
} catch (e) {
2526
const err = e instanceof Error ? e.message : `error: ${JSON.stringify(e)}`;
2627
reply(m.portId, m.req.handlerId, { tag: "Err", err });
27-
},
28-
);
28+
}
29+
});
2930
},
3031
};
3132
})();

0 commit comments

Comments
 (0)