# Syncronously initializing CSG2?

**URL:** <https://forum.babylonjs.com/t/syncronously-initializing-csg2/55620>\
**Category:** Questions\
**Tags:** csg2\
**Created:** [December 29, 2024, 1:45am UTC](https://forum.babylonjs.com/t/syncronously-initializing-csg2/55620 "2024-12-29T01:45:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HiGreg](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Post date:** [December 29, 2024, 1:45am UTC](https://forum.babylonjs.com/t/syncronously-initializing-csg2/55620/1 "2024-12-29T01:45:46Z")

</div>

How do I initialize CGS2 syncronously from within a non-async function?

If I use _await BABYLON.InitializeCSG2Async();_, it has to be within an async function. Then _that_ function becomes asyncronous itself, right?

Can I avoid polling with _IsCSG2Ready()_?

Maybe I misunderstand async/await.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 30, 2024, 11:03pm UTC](https://forum.babylonjs.com/t/syncronously-initializing-csg2/55620/2 "2024-12-30T23:03:51Z")

</div>

You can not really convert a promise based code in a synchronous one.

> If I use _await BABYLON.InitializeCSG2Async();_ , it has to be within an async function. Then _that_ function becomes asyncronous itself, right?

Yes and you could also keep the caller sync but in your function do something like:

```auto
BABYLON.InitializeCSG2Async()
  .then(() => { yourCode(); });
  .catch((e) => { yourErrorCode(e); });

```

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [December 31, 2024, 12:52am UTC](https://forum.babylonjs.com/t/syncronously-initializing-csg2/55620/3 "2024-12-31T00:52:58Z")

</div>

That’s due to the limitation of wasm module size (4k) of [`WebAssembly.Module`](https://developer.mozilla.org/zh-CN/docs/WebAssembly/JavaScript_interface/Module) and [`WebAssembly.Instance`](https://developer.mozilla.org/zh-CN/docs/WebAssembly/JavaScript_interface/Instance) constructors, which is the sync api to use wasm.  
See this for more detail.  
[https://chromestatus.com/feature/5099433642950656](https://chromestatus.com/feature/5099433642950656)  
[https://groups.google.com/a/chromium.org/g/blink-dev/c/nJw2zwaiJ2s/m/EYPgC5D3LwAJ](https://groups.google.com/a/chromium.org/g/blink-dev/c/nJw2zwaiJ2s/m/EYPgC5D3LwAJ)
