Skip to content

[BUG]: "Database already exists" and websockets errors when reloading the page with your sample code #48

@draeder

Description

@draeder

Version:
Current from CDN

Platform:
Browser

Describe the bug
I am getting the following errors when I reload the browser page running your sample browser code from: https://simpleaswater.com/intro-to-aviondb/

Numerous instances of:

WebSocket connection to 'ws://127.0.0.1:8081/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
t.exports @ index.min.js:2
_connect @ index.min.js:2
dial @ index.min.js:2
dial @ index.min.js:2
dialAction @ index.min.js:2
(anonymous) @ index.min.js:2

WebSocket connection to 'ws://127.0.0.1:8081/p2p/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm' failed: WebSocket is closed before the connection is established.
(anonymous) @ index.min.js:2
c.close @ index.min.js:2
o @ index.min.js:2
r @ index.min.js:2
(anonymous) @ index.min.js:2
run @ index.min.js:2
async function (async)
run @ index.min.js:2
_createPendingDial @ index.min.js:2
connectToPeer @ index.min.js:2
_maybeConnect @ index.min.js:2
_onDidStart @ index.min.js:2
start @ index.min.js:2
async function (async)
start @ index.min.js:2
(anonymous) @ index.min.js:2
async function (async)
(anonymous) @ index.min.js:2
(anonymous) @ index.min.js:2
create @ index.min.js:2
async function (async)
create @ index.min.js:2
runExample @ aviondb.html:10
(anonymous) @ aviondb.html:67

Followed by:

Uncaught (in promise) Error: Database '/orbitdb/zdpuAn2qsM6P9E3DKz1hL4pUEaJwGqUh7LEX4eCnzgwABoeZV/employees' already exists!
    at k.create (aviondb.min.js:25)
create @ aviondb.min.js:25
async function (async)
runExample @ aviondb.html:10
(anonymous) @ aviondb.html:67

It would seem to me that by using aviondb.initCollection("employees"); it should simply open the existing collection, not try to create a new one.

Also, it would seem to me that by using await aviondb.drop(); the collection would be removed along with the database.

What else is notable here, is if I delete the databases in IndexedDB upon page reload, the issue does not happen. But that causes me to wonder if it's because my ipfs node ID is changing in that scenario and therefore I no longer can access the previously created database and collection.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions