# IDBStorageEnabled throws invalid url error

**URL:** <https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475>\
**Category:** Questions\
**Created:** [May 1, 2021, 3:27am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475 "2021-05-01T03:27:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![phaselock](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@phaselock](https://forum.babylonjs.com/u/phaselock)\
**Post date:** [May 1, 2021, 3:27am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/1 "2021-05-01T03:27:32Z")

</div>

erm, not sure how to repro this on PG.  
`IDBStorageEnabled = true` throws errors. I’m getting in ffox:

`Uncaught TypeError: URL constructor: mydir/myfile.babylon is not a valid URL.`

and in chrome:

```auto
Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at n (babylon.js:16)
    at e._checkManifestFile (babylon.js:16)
    at new e (babylon.js:16)
    at Function.Pe.a.OfflineProviderFactory (babylon.js:16)
    at Function.e._LoadData (babylon.js:16)
    at Function.e.ImportMesh (babylon.js:16)
    at t.runTask (babylon.js:16)
    at t.e.run (babylon.js:16)
    at e._runTask (babylon.js:16)
    at e.load (babylon.js:16)

```

I have a myfile.babylon.manifest in mydir. If I switch off IDBStorageEnabled, the error goes away. I presume there is some recent work on databases. Kindly advise what changes I should make on my end ?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 3, 2021, 8:56am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/2 "2021-05-03T08:56:35Z")

</div>

Hi, did you recently upgrade to a new version of babylon? or are you using the preview cdn version?

Could you share the code? the URL parser was just recently changed, will be great to catch all of those errors and fix them asap

---

<div class="post-metadata">

**Author:** ![phaselock](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@phaselock](https://forum.babylonjs.com/u/phaselock)\
**Post date:** [May 4, 2021, 3:22am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/3 "2021-05-04T03:22:20Z")

</div>

> [@RaananW](#):
>
> Hi, did you recently upgrade to a new version of babylon? or are you using the preview cdn version?

console shows: `Babylon.js v5.0.0-alpha.19 - WebGL2`

> [@RaananW](#):
>
> Could you share the code? the URL parser was just recently changed, will be great to catch all of those errors and fix them asap

The line that triggers the error in my code is:

`let tierAssetLoadMeshTask = tierAssetsManager.addMeshTask("tierAssetLoadMeshTask", basic_assets, "mydir/","myfile.babylon");`

When I changed it to:  
`let tierAssetLoadMeshTask = tierAssetsManager.addMeshTask("tierAssetLoadMeshTask", basic_assets, "http://mydir/","myfile.babylon");`

The invalid url error goes away to be replaced by cross-origin error which is as expected. I’m guessing your url parser needs the http protocol and does not deal with urls on local network?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 4, 2021, 8:19am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/4 "2021-05-04T08:19:55Z")

</div>

I guess the interesting part of it all is the fact that this function doesn’t return a valid URL with schema:

```javascript
private static _ReturnFullUrlLocation = (url: string): string => {
        if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1 && typeof window !== "undefined") {
            return (Database._ParseURL(window.location.href) + url);
        }
        else {
            return url;
        }
    }

```

I am fixing it now (falling back if there is an exception), but have a few more questions 🙂

The first one would be - how do you host this? is it a localhost server, or using files on your harddrive?  
if it is a webserver, what does `window.location.href` return?

Thanks!

---

<div class="post-metadata">

**Author:** ![phaselock](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@phaselock](https://forum.babylonjs.com/u/phaselock)\
**Post date:** [May 4, 2021, 8:40am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/5 "2021-05-04T08:40:14Z")

</div>

> [@RaananW](#):
>
> The first one would be - how do you host this? is it a localhost server, or using files on your harddrive?

My development is on localhost (nodeJS), files are all on my harddrive atm. Will eventually move to webserver, but not now.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 4, 2021, 8:41am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/6 "2021-05-04T08:41:34Z")

</div>

but you are not using the file:// protocol, right?

---

<div class="post-metadata">

**Author:** ![phaselock](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@phaselock](https://forum.babylonjs.com/u/phaselock)\
**Post date:** [May 4, 2021, 8:45am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/7 "2021-05-04T08:45:16Z")

</div>

> [@RaananW](#):
>
> but you are not using the file:// protocol, right?

Nope. Not using file:// protocol

> [@RaananW](#):
>
> what does `window.location.href` return?

Just chked, console logs `http://localhost:1001/`, 1001 is my current arbitrary dev port.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 4, 2021, 9:52am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/8 "2021-05-04T09:52:47Z")

</div>

odd, it should work out of the box. I’ll try reproducing it locally. In the meantime, this PR will solve this - [defensive URL parsing by RaananW · Pull Request #10312 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/10312)

---

<div class="post-metadata">

**Author:** ![phaselock](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@phaselock](https://forum.babylonjs.com/u/phaselock)\
**Post date:** [May 5, 2021, 12:36am UTC](https://forum.babylonjs.com/t/idbstorageenabled-throws-invalid-url-error/20475/9 "2021-05-05T00:36:04Z")

</div>

Fix works, tyvm !
