Skip to content

Commit

Permalink
Merge pull request #148 from rhashimoto/bug-143-again
Browse files Browse the repository at this point in the history
Fix #143 for Safari (no ArrayBuffer.prototype.detached)
  • Loading branch information
rhashimoto authored Jan 19, 2024
2 parents 0477ca5 + be1b8f2 commit 390744d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wa-sqlite",
"version": "0.9.10",
"version": "0.9.11",
"type": "module",
"main": "src/sqlite-api.js",
"types": "src/types/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/examples/IDBBatchAtomicVFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class IDBBatchAtomicVFS extends VFS.Base {
});

// @ts-ignore
if (pOutFlags.buffer.detached) {
if (pOutFlags.buffer.detached || !pOutFlags.buffer.byteLength) {
pOutFlags = new DataView(new ArrayBuffer(4));
this.#growthHandler = (pOutFlagsNew) => {
pOutFlagsNew.setInt32(0, pOutFlags.getInt32(0, true), true);
Expand Down Expand Up @@ -190,7 +190,7 @@ export class IDBBatchAtomicVFS extends VFS.Base {
// write boundaries so we have to allow for that.
const result = await this.#idb.run('readonly', async ({blocks}) => {
// @ts-ignore
if (pData.buffer.detached) {
if (pData.buffer.detached || !pData.buffer.byteLength) {
// WebAssembly memory has grown, invalidating our buffer. Use
// a temporary buffer and copy after this asynchronous call
// completes.
Expand Down Expand Up @@ -477,7 +477,7 @@ export class IDBBatchAtomicVFS extends VFS.Base {
};

// @ts-ignore
if (pResOut.buffer.detached) {
if (pResOut.buffer.detached || !pResOut.buffer.byteLength) {
pResOut = new DataView(new ArrayBuffer(4));
this.#growthHandler = (pResOutNew) => {
pResOutNew.setInt32(0, pResOut.getInt32(0, true), true);
Expand Down Expand Up @@ -668,7 +668,7 @@ export class IDBBatchAtomicVFS extends VFS.Base {
});

// @ts-ignore
if (pResOut.buffer.detached) {
if (pResOut.buffer.detached || !pResOut.buffer.byteLength) {
pResOut = new DataView(new ArrayBuffer(4));
this.#growthHandler = (pResOutNew) => {
pResOutNew.setInt32(0, pResOut.getInt32(0, true), true);
Expand Down

0 comments on commit 390744d

Please sign in to comment.