Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set Dexie.debug to true? #1806

Open
lucasrodrigues10 opened this issue Sep 27, 2023 · 4 comments
Open

How to set Dexie.debug to true? #1806

lucasrodrigues10 opened this issue Sep 27, 2023 · 4 comments

Comments

@lucasrodrigues10
Copy link

I'm using Dexie "3.2.1" and can't find a way to set Dexie.debug to true.

This is the docs which I used as reference.
https://dexie.org/docs/Dexie/Dexie.debug

Can you help me?

@dfahlander
Copy link
Collaborator

Typings are missing for Dexie.debug but it will respect it in regards of console logging. dexie-cloud-addon does not yet respect this value but a new version coming out soon will fix this. See #1801 .

@kheos31
Copy link

kheos31 commented Jan 10, 2024

Hello @dfahlander !

I just saw this issue after I checked the typing and test on my own your enunciated solution.. But it doesn't work currently.. Or at least, it does not seem to have the behavior announced into the doc.

image

For example, this code with the valorization of debug at these 2 places, using just one valorization or the other, or without valorization of debug property, give me this stack :

An error was thrown in afterAll
Unhandled promise rejection: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
 DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
error properties: Object({ _e: Error, inner: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified., _promise: [object Dexie.Promise] })
Error: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3153:39)
    at executePromiseTask (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:797:9)
    at new DexiePromise (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:616:5)
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
From previous: 
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1235:20
Unhandled promise rejection: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
 DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
error properties: Object({ _e: Error, inner: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified., _promise: [object Dexie.Promise] })
Error: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3153:39)
    at executePromiseTask (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:797:9)
    at new DexiePromise (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:616:5)
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
From previous: 
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1235:20
Unhandled promise rejection: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
 DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
error properties: Object({ _e: Error, inner: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified., _promise: [object Dexie.Promise] })
Error: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3153:39)
    at executePromiseTask (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:797:9)
    at new DexiePromise (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:616:5)
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
From previous: 
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1235:20
Unhandled promise rejection: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
 DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
error properties: Object({ _e: Error, inner: DataError: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified., _promise: [object Dexie.Promise] })
Error: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3153:39)
    at executePromiseTask (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:797:9)
    at new DexiePromise (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:616:5)
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
From previous: 
    at Object.apply (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:3150:24)
    at Object.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:4464:46)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1313:30)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1294:20)
    at fn (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1237:24)
    at usePSD (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1143:16)
    at newScope (http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1047:14)
    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/dexie/dist/modern/dexie.mjs:1235:20

No info for the origin of this error in my own code. Is it normal? Does I valorized the property badly?

NB: I found finally the problem after a little day lost on my own bad code, but I would prefer an info about the source caller if this kind of error will be produced..

Thanks in advance.

@dfahlander
Copy link
Collaborator

Thanks! This kind of error should be validated earlier in Table.get() to prohibit this kind of native error happening deep within dexie. The async call stack doesn't reveal much. Would also want to look into how Dexie could use Chrome's new async stack tagging Api do improve the call stack.

@kheos31
Copy link

kheos31 commented Jan 11, 2024

Thanks for response, sounds great for the future so! :D
Thanks for this great lib and impatient to try Dexie 4 and discover all new features!

dfahlander added a commit that referenced this issue Jan 22, 2024
It's a common pitfall to do db.someTable.get(someVariable) without checking that someVariable isn't null.

This is a common pitfall and in the case the call to Table.get() is the initial db call that the application makes, the call stack will be totally unreadable because:

1. Table.get() will first asynchronically auto-open the database.
2. Whe DB is finally opened it will fail deep inside DBCore leaving the user with an unreadable call stack.

See #1806 (comment)
dfahlander added a commit that referenced this issue Jan 22, 2024
…k() instead.

We used to have own special support for long async stacks to simplify debugging. However, now all browsers already have long async stacks supported in devtools.
This commit removes all special code that deals with long stack support.
It also introduces the usage of Chrome's Async Stack Tagging API (console.createTask()) that makes it easier to follow console traces on exceptions and find the application code that initiated the operation.

Also, when Dexie.debug is true, we trace all errors from dexie operations with the help of async stack tagging, hopefully making it easier for app developers to find issues in app code.

See #1806
dfahlander added a commit that referenced this issue Feb 7, 2024
* Fail fast on Table.get(undefined)

It's a common pitfall to do db.someTable.get(someVariable) without checking that someVariable isn't null.

This is a common pitfall and in the case the call to Table.get() is the initial db call that the application makes, the call stack will be totally unreadable because:

1. Table.get() will first asynchronically auto-open the database.
2. Whe DB is finally opened it will fail deep inside DBCore leaving the user with an unreadable call stack.

See #1806 (comment)

* Cleanse out old "long stacks" support. Use Chrome's console.createTask() instead.
We used to have own special support for long async stacks to simplify debugging. However, now all browsers already have long async stacks supported in devtools.
This commit removes all special code that deals with long stack support.
It also introduces the usage of Chrome's Async Stack Tagging API (console.createTask()) that makes it easier to follow console traces on exceptions and find the application code that initiated the operation.

Also, when Dexie.debug is true, we trace all errors from dexie operations with the help of async stack tagging, hopefully making it easier for app developers to find issues in app code.

See #1806

* Remove polyfills from test page

* Remove _stackHolder not needed anymore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants