indexedDB is not defined

921 views
Skip to first unread message

mobin shaterian

unread,
Jul 6, 2021, 8:18:11 AM7/6/21
to Tinode General
I want connection to chat server via Nodejs as client. running server by docker and no problem has occurred .

for connect to server via Nodejs i writing code bellow


const express = require('express');
const app = express();
const Tinode = require('tinode-sdk');
// const Tinode = require('indexeddb');

app.listen(4000, () => {
console.log('server is running on port 3000')

chat();
});


const chat = (() => {
Tinode.setNetworkProviders(require('ws'), require('xmlhttprequest'));
const indexedDB = require("fake-indexeddb");
console.log(indexedDB)
const tinode = new Tinode({appName: 'TinodeWeb/0.17' , host: '127.0.0.1:6060', apiKey: 'AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K', transport: 'ws',persist:true},'resolve');
console.log(tinode);
})




and getting this error .

(node:27476) UnhandledPromiseRejectionWarning: ReferenceError: indexedDB is not defined
    at /home/mobin/Documents/tinod_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1331:25
    at new Promise (<anonymous>)
    at Object.initDatabase (/home/mobin/Documents/tinod_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1328:18)
    at new Tinode (/home/mobin/Documents/tinod_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:4683:18)
    at chat (/home/mobin/Documents/tinod_nodejs/index.js:19:20)
    at Server.<anonymous> (/home/mobin/Documents/tinod_nodejs/index.js:10:5)
    at Object.onceWrapper (events.js:481:28)
    at Server.emit (events.js:375:28)
    at emitListeningNT (net.js:1354:10)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:27476) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:27476) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


Gene

unread,
Jul 6, 2021, 12:01:11 PM7/6/21
to Tinode General
Yes, it's a bug. I'll release the fix later today.

Gene

unread,
Jul 6, 2021, 12:36:05 PM7/6/21
to Tinode General
Fixed in https://github.com/tinode/tinode-js/commit/251791419405bf51ce4c269286102240f99160e7
Please test and let me know.

Tinode.setDatabaseProvider(require('fake-indexeddb'));

Thanks.

mobin shaterian

unread,
Jul 7, 2021, 3:22:47 AM7/7/21
to Tinode General
Thanks Gene

I pushed my code in this Github repository in order to check out to see all I have done is correct.


I'd appreciate your concern to resolve the previously mentioned bug, after I added your new command, another issue showed up which is reported here:


(node:10769) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'deleteDatabase' of undefined
    at /home/mobin/Documents/tinode_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1:9905

    at new Promise (<anonymous>)
    at Object.deleteDatabase (/home/mobin/Documents/tinode_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1:9875)
    at new v (/home/mobin/Documents/tinode_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1:38079)
    at chat (/home/mobin/Documents/tinode_nodejs/index.js:19:20)
    at Server.<anonymous> (/home/mobin/Documents/tinode_nodejs/index.js:10:5)

    at Object.onceWrapper (events.js:481:28)
    at Server.emit (events.js:375:28)
    at emitListeningNT (net.js:1354:10)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10769) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:10769) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.



kind regards,

mobin shaterian

unread,
Jul 7, 2021, 4:20:25 AM7/7/21
to Tinode General
I'm changing new Tinode to websocket  but another issue showed up which is reported here:
(node:14131) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'open' of undefined
    at /home/mobin/Documents/tinode_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1:9345

    at new Promise (<anonymous>)
    at Object.initDatabase (/home/mobin/Documents/tinode_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1:9315)
    at new v (/home/mobin/Documents/tinode_nodejs/node_modules/tinode-sdk/umd/tinode.prod.js:1:37657)
    at chat (/home/mobin/Documents/tinode_nodejs/index.js:18:20)

    at Server.<anonymous> (/home/mobin/Documents/tinode_nodejs/index.js:10:5)
    at Object.onceWrapper (events.js:481:28)
    at Server.emit (events.js:375:28)
    at emitListeningNT (net.js:1354:10)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:14131) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:14131) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


kind regards,

Gene

unread,
Jul 7, 2021, 11:21:57 AM7/7/21
to Tinode General
These two issues are on your end. You are not initializing the providers properly. Please debug the issues and let me know if anything needs to be changed on our end.
Reply all
Reply to author
Forward
0 new messages