Closed terryluan12 closed 4 months ago
It actually seems that the code errors because IDBFactory is not defined within Node. Attempting to find a fix for that. Irregardless, the error still occurs without the type error because globalThis.indexedDB
is not initially defined
@terryluan12 This is intentional behavior. As you undoubtedly know, Node is not a browser so browser APIs are not available. You should not use @zenfs/dom
outside of a browser environment, since it depends on DOM/browser APIs for everything. Does that clear things up?
Ahhhh. I see, it does! I do see it running fine browser-side, but I think the server side is also running the code (I'm using NextJS). Thank you
Within
IndexedDB.ts:isAvailable
, there is a try catch statement, which defaults toglobalThis.indexedDB
. Within the typecheck (line 134),globalThis.indexedDB
eventually becomes available, but initially, when attempting to access it, it returns an error becauseidbFactory
isundefined
. However because it's undefined when attempting to delete database in the catch statement, it returns an error.