From f49f37e75543e2fc5f5d484fb5179f9bac8dc6e6 Mon Sep 17 00:00:00 2001 From: Victor Lyuboslavsky Date: Thu, 1 Feb 2024 15:21:46 -0600 Subject: [PATCH] Updating wa-sqlite to latest version. (#16484) This is a speculative fix for #16394 RuntimeError, which was coming from wa-sqlite web assembly code. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. - [x] Manual QA for all new/changed functionality --- changes/16394-fleetd-chrome-runtime-error | 1 + ee/fleetd-chrome/package-lock.json | 10 +++---- ee/fleetd-chrome/package.json | 4 +-- ee/fleetd-chrome/src/tables/Table.ts | 32 +++++++++++------------ ee/fleetd-chrome/updates-beta.xml | 2 +- ee/fleetd-chrome/updates.xml | 2 +- 6 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 changes/16394-fleetd-chrome-runtime-error diff --git a/changes/16394-fleetd-chrome-runtime-error b/changes/16394-fleetd-chrome-runtime-error new file mode 100644 index 0000000000..d6c03976d2 --- /dev/null +++ b/changes/16394-fleetd-chrome-runtime-error @@ -0,0 +1 @@ +Updated fleetd-chrome to use the latest wa-sqlite v0.9.11 diff --git a/ee/fleetd-chrome/package-lock.json b/ee/fleetd-chrome/package-lock.json index 88dcee0b46..32acbb5131 100644 --- a/ee/fleetd-chrome/package-lock.json +++ b/ee/fleetd-chrome/package-lock.json @@ -1,15 +1,15 @@ { "name": "fleetd-for-chrome", - "version": "1.1.0", + "version": "1.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "fleetd-for-chrome", - "version": "1.1.0", + "version": "1.1.3", "dependencies": { "dotenv": "^16.0.3", - "wa-sqlite": "github:rhashimoto/wa-sqlite#buildless" + "wa-sqlite": "github:rhashimoto/wa-sqlite#v0.9.11" }, "devDependencies": { "@jest/globals": "^29.5.0", @@ -8322,8 +8322,8 @@ } }, "node_modules/wa-sqlite": { - "version": "0.8.9", - "resolved": "git+ssh://git@github.com/rhashimoto/wa-sqlite.git#595b1047f687377322474e427dc19c12606fe04a" + "version": "0.9.11", + "resolved": "git+ssh://git@github.com/rhashimoto/wa-sqlite.git#390744d41c61aa0bbd53d3c738abef5e23f71cc4" }, "node_modules/walker": { "version": "1.0.8", diff --git a/ee/fleetd-chrome/package.json b/ee/fleetd-chrome/package.json index d05a21425e..e1a0d61b73 100644 --- a/ee/fleetd-chrome/package.json +++ b/ee/fleetd-chrome/package.json @@ -1,10 +1,10 @@ { "name": "fleetd-for-chrome", "description": "Extension for Fleetd on ChromeOS", - "version": "1.1.1", + "version": "1.1.3", "dependencies": { "dotenv": "^16.0.3", - "wa-sqlite": "github:rhashimoto/wa-sqlite#buildless" + "wa-sqlite": "github:rhashimoto/wa-sqlite#v0.9.11" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/ee/fleetd-chrome/src/tables/Table.ts b/ee/fleetd-chrome/src/tables/Table.ts index 46d48f11ed..93deadb6e1 100644 --- a/ee/fleetd-chrome/src/tables/Table.ts +++ b/ee/fleetd-chrome/src/tables/Table.ts @@ -50,7 +50,7 @@ export default abstract class Table implements SQLiteModule { // This is replaced by wa-sqlite when SQLite is loaded up, but missing from the SQLiteModule // definition. We add it here to make Typescript happy. - handleAsync(f: () => Promise): Promise { + handleAsync(_: () => Promise): number { throw new Error("should be replaced in build"); } @@ -61,37 +61,37 @@ export default abstract class Table implements SQLiteModule { appData: any, // Application data passed to `SQLiteAPI.create_module`. argv: Array, pVTab: number, - pzString: { set: (arg0: string) => void } - ): number | Promise { + pzErr: DataView, + ): number { // Register the table schema. const sql = `CREATE TABLE ${this.name} (${this.columns.join(",")})`; - pzString.set(sql); + this.sqlite3.declare_vtab(db, sql); return SQLite.SQLITE_OK; } xBestIndex( pVTab: number, indexInfo: SQLiteModuleIndexInfo - ): number | Promise { + ): number { // In the future we might be able to use this for some tables to optimize queries. return SQLite.SQLITE_OK; } - xDisconnect(pVTab: number): number | Promise { + xDisconnect(pVTab: number): number { return SQLite.SQLITE_OK; } - xDestroy(pVTab: number): number | Promise { + xDestroy(pVTab: number): number { return SQLite.SQLITE_OK; } - xOpen(pVTab: number, pCursor: number): number | Promise { + xOpen(pVTab: number, pCursor: number): number { // Initialize a new cursor state (called at the beginning of a query to the table). this.cursorStates.set(pCursor, new cursorState()); return SQLite.SQLITE_OK; } - xClose(pCursor: number): number | Promise { + xClose(pCursor: number): number { // Clean up the cursor state (called when the query completes). Important that we do this so // that the resources don't remain allocated after the query completes! this.cursorStates.delete(pCursor); @@ -103,7 +103,7 @@ export default abstract class Table implements SQLiteModule { idxNum: number, idxStr: string | null, values: Array - ): Promise { + ): number { // Generate the actual query results here during this filter call. Store them in the cursor state // so that SQLite can request each row and column. return this.handleAsync(async () => { @@ -130,14 +130,14 @@ export default abstract class Table implements SQLiteModule { }); } - xNext(pCursor: number): number | Promise { + xNext(pCursor: number): number { // Advance the row index for the cursor. const cursorState = this.cursorStates.get(pCursor); cursorState.rowIndex += 1; return SQLite.SQLITE_OK; } - xEof(pCursor: number): number | Promise { + xEof(pCursor: number): number { // Check whether we've returned all rows (cursor index is beyond number of rows). const cursorState = this.cursorStates.get(pCursor); // Throw any error saved in the cursor state (because throwing in xFilter doesn't seem to work @@ -152,7 +152,7 @@ export default abstract class Table implements SQLiteModule { pCursor: number, pContext: number, iCol: number - ): number | Promise { + ): number { // Get the generated rows for this cursor. const cursorState = this.cursorStates.get(pCursor); // Get the current row. @@ -167,11 +167,11 @@ export default abstract class Table implements SQLiteModule { xRowid( pCursor: number, - pRowid: { set: (arg0: number) => void } - ): number | Promise { + pRowid: DataView, + ): number { // Get the current row index. const cursorState = this.cursorStates.get(pCursor); - pRowid.set(cursorState.rowIndex); + pRowid.setBigInt64(0, BigInt(cursorState.rowIndex)); return SQLite.SQLITE_OK; } } diff --git a/ee/fleetd-chrome/updates-beta.xml b/ee/fleetd-chrome/updates-beta.xml index 0444251d64..668c0f64dd 100644 --- a/ee/fleetd-chrome/updates-beta.xml +++ b/ee/fleetd-chrome/updates-beta.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/ee/fleetd-chrome/updates.xml b/ee/fleetd-chrome/updates.xml index 433bfddc79..9881e92035 100644 --- a/ee/fleetd-chrome/updates.xml +++ b/ee/fleetd-chrome/updates.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file