zen-fs / dom

DOM backends for ZenFS
https://zenfs.dev/dom/
MIT License
12 stars 4 forks source link

Issue with idbFactory Setup #16

Closed terryluan12 closed 4 months ago

terryluan12 commented 4 months ago

Within IndexedDB.ts:isAvailable, there is a try catch statement, which defaults to globalThis.indexedDB. Within the typecheck (line 134), globalThis.indexedDB eventually becomes available, but initially, when attempting to access it, it returns an error because idbFactory is undefined. However because it's undefined when attempting to delete database in the catch statement, it returns an error.

terryluan12 commented 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

james-pre commented 4 months ago

@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?

terryluan12 commented 4 months ago

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