Skip to content

Commit 390744d

Browse files
authored
Merge pull request rhashimoto#148 from rhashimoto/bug-143-again
Fix rhashimoto#143 for Safari (no ArrayBuffer.prototype.detached)
2 parents 0477ca5 + be1b8f2 commit 390744d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wa-sqlite",
3-
"version": "0.9.10",
3+
"version": "0.9.11",
44
"type": "module",
55
"main": "src/sqlite-api.js",
66
"types": "src/types/index.d.ts",

src/examples/IDBBatchAtomicVFS.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class IDBBatchAtomicVFS extends VFS.Base {
126126
});
127127

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

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

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

0 commit comments

Comments
 (0)