Skip to content

Commit

Permalink
Replace setImmedaite with setTimeout - fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Oct 11, 2021
1 parent be0551e commit 17c1547
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 18 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"lib"
],
"dependencies": {
"realistic-structured-clone": "^2.0.1",
"setimmediate": "^1.0.5"
"realistic-structured-clone": "^2.0.1"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
Expand Down
2 changes: 1 addition & 1 deletion src/FDBDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const closeConnection = (connection: FDBDatabase) => {
},
);
} else {
setImmediate(() => {
setTimeout(() => {
closeConnection(connection);
});
}
Expand Down
13 changes: 6 additions & 7 deletions src/FDBFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "setimmediate";
import FDBDatabase from "./FDBDatabase";
import FDBOpenDBRequest from "./FDBOpenDBRequest";
import FDBVersionChangeEvent from "./FDBVersionChangeEvent";
Expand All @@ -19,7 +18,7 @@ const waitForOthersClosedDelete = (
});

if (anyOpen) {
setImmediate(() =>
setTimeout(() =>
waitForOthersClosedDelete(databases, name, openDatabases, cb),
);
return;
Expand Down Expand Up @@ -123,7 +122,7 @@ const runVersionchangeTransaction = (
});

if (anyOpen2) {
setImmediate(waitForOthersClosed);
setTimeout(waitForOthersClosed);
return;
}

Expand Down Expand Up @@ -160,15 +159,15 @@ const runVersionchangeTransaction = (
transaction.addEventListener("abort", () => {
connection._runningVersionchangeTransaction = false;
request.transaction = null;
setImmediate(() => {
setTimeout(() => {
cb(new AbortError());
});
});
transaction.addEventListener("complete", () => {
connection._runningVersionchangeTransaction = false;
request.transaction = null;
// Let other complete event handlers run before continuing
setImmediate(() => {
setTimeout(() => {
if (connection._closePending) {
cb(new AbortError());
} else {
Expand Down Expand Up @@ -229,7 +228,7 @@ class FDBFactory {
const request = new FDBOpenDBRequest();
request.source = null;

setImmediate(() => {
setTimeout(() => {
const db = this._databases.get(name);
const oldVersion = db !== undefined ? db.version : 0;

Expand Down Expand Up @@ -278,7 +277,7 @@ class FDBFactory {
const request = new FDBOpenDBRequest();
request.source = null;

setImmediate(() => {
setTimeout(() => {
openDatabase(
this._databases,
name,
Expand Down
4 changes: 2 additions & 2 deletions src/FDBTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class FDBTransaction extends FakeEventTarget {
}
}

setImmediate(() => {
setTimeout(() => {
const event = new FakeEvent("abort", {
bubbles: true,
cancelable: false,
Expand Down Expand Up @@ -228,7 +228,7 @@ class FDBTransaction extends FakeEventTarget {
}

// Give it another chance for new handlers to be set before finishing
setImmediate(this._start.bind(this));
setTimeout(this._start.bind(this));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Database {
}

public processTransactions() {
setImmediate(() => {
setTimeout(() => {
const anyRunning = this.transactions.some(transaction => {
return (
transaction._started && transaction._state !== "finished"
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2539,11 +2539,6 @@ set-blocking@^2.0.0:
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=

setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=

sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4:
version "2.4.11"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7"
Expand Down

0 comments on commit 17c1547

Please sign in to comment.