Skip to content

Commit c2d50c8

Browse files
authored
Merge pull request #36 from powersync-ja/upstream-changes
Pull upstream changes
2 parents 968f936 + 8eba6ae commit c2d50c8

32 files changed

+494
-94
lines changed

.changeset/proud-moose-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@journeyapps/wa-sqlite': patch
3+
---
4+
5+
Fix issue where OPFS VFS could freeze in infinite loop

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ EMFLAGS_COMMON = \
8484
-s INVOKE_RUN \
8585
-s ENVIRONMENT="web,worker" \
8686
-s STACK_SIZE=512KB \
87+
-s WASM_BIGINT=0 \
8788
$(EMFLAGS_EXTRA)
8889

8990
EMFLAGS_DEBUG = \

demo/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ window.addEventListener('DOMContentLoaded', async function() {
7777
let time = performance.now();
7878
worker.postMessage(queries);
7979
worker.addEventListener('message', async function(event) {
80+
timestamp.textContent += ` ${(performance.now() - time).toFixed(1)} milliseconds`;
8081
if (event.data.results) {
8182
// Format the results as tables.
8283
event.data.results
@@ -85,7 +86,6 @@ window.addEventListener('DOMContentLoaded', async function() {
8586
} else {
8687
output.innerHTML = `<pre>${event.data.error.message}</pre>`;
8788
}
88-
timestamp.textContent += ` ${Math.trunc(performance.now() - time) / 1000} seconds`;
8989
button.disabled = false;
9090
}, { once: true });
9191
});

demo/file/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as VFS from "../../src/VFS.js";
2-
import { IDBBatchAtomicVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
2+
import { IDBBatchAtomicVFS as MyVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
3+
// import { IDBMirrorVFS as MyVFS } from "../../src/examples/IDBMirrorVFS.js";
34

45
const SEARCH_PARAMS = new URLSearchParams(location.search);
56
const IDB_NAME = SEARCH_PARAMS.get('idb') ?? 'sqlite-vfs';
@@ -43,7 +44,7 @@ document.getElementById('file-fetch').addEventListener('click', async () => {
4344
let vfs;
4445
try {
4546
log(`Importing to IndexedDB ${IDB_NAME}, path ${DB_NAME}`);
46-
vfs = await IDBBatchAtomicVFS.create(IDB_NAME, null);
47+
vfs = await MyVFS.create(IDB_NAME, null);
4748

4849
// @ts-ignore
4950
const importURL = document.getElementById('file-url').value;
@@ -69,7 +70,7 @@ document.getElementById('file-import').addEventListener('change', async event =>
6970
let vfs;
7071
try {
7172
log(`Importing to IndexedDB ${IDB_NAME}, path ${DB_NAME}`);
72-
vfs = await IDBBatchAtomicVFS.create(IDB_NAME, null);
73+
vfs = await MyVFS.create(IDB_NAME, null);
7374
// @ts-ignore
7475
await importDatabase(vfs, DB_NAME, event.target.files[0].stream());
7576
log('Import complete');
@@ -87,7 +88,7 @@ document.getElementById('file-import').addEventListener('change', async event =>
8788
});
8889

8990
/**
90-
* @param {IDBBatchAtomicVFS} vfs
91+
* @param {MyVFS} vfs
9192
* @param {string} path
9293
* @param {ReadableStream} stream
9394
*/

demo/file/service-worker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as VFS from "../../src/VFS.js";
2-
import { IDBBatchAtomicVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
2+
import { IDBBatchAtomicVFS as MyVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
3+
// import { IDBMirrorVFS as MyVFS } from "../../src/examples/IDBMirrorVFS.js";
34

45
// Install the service worker as soon as possible.
56
globalThis.addEventListener('install', (/** @type {ExtendableEvent} */ event) => {
@@ -26,7 +27,7 @@ globalThis.addEventListener('fetch', async (/** @type {FetchEvent} */ event) =>
2627

2728
return event.respondWith((async () => {
2829
// Create the VFS and streaming source using the request parameters.
29-
const vfs = await IDBBatchAtomicVFS.create(url.searchParams.get('idb'), null);
30+
const vfs = await MyVFS.create(url.searchParams.get('idb'), null);
3031
const path = url.searchParams.get('db');
3132
const source = new DatabaseSource(vfs, path);
3233

demo/file/verifier.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SQLiteESMFactory from '../../dist/wa-sqlite-async.mjs';
22
import * as SQLite from '../../src/sqlite-api.js';
3-
import { IDBBatchAtomicVFS } from '../../src/examples/IDBBatchAtomicVFS.js';
3+
import { IDBBatchAtomicVFS as MyVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
4+
// import { IDBMirrorVFS as MyVFS } from "../../src/examples/IDBMirrorVFS.js";
45

56
const SEARCH_PARAMS = new URLSearchParams(location.search);
67
const IDB_NAME = SEARCH_PARAMS.get('idb') ?? 'sqlite-vfs';
@@ -10,7 +11,7 @@ const DB_NAME = SEARCH_PARAMS.get('db') ?? 'sqlite.db';
1011
const module = await SQLiteESMFactory();
1112
const sqlite3 = SQLite.Factory(module);
1213

13-
const vfs = await IDBBatchAtomicVFS.create(IDB_NAME, module);
14+
const vfs = await MyVFS.create(IDB_NAME, module);
1415
// @ts-ignore
1516
sqlite3.vfs_register(vfs, true);
1617

dist/mc-wa-sqlite-async.mjs

Lines changed: 2 additions & 3 deletions
Large diffs are not rendered by default.

dist/mc-wa-sqlite-async.wasm

-403 Bytes
Binary file not shown.

dist/mc-wa-sqlite-jspi.mjs

Lines changed: 2 additions & 3 deletions
Large diffs are not rendered by default.

dist/mc-wa-sqlite-jspi.wasm

41 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)