# Share as Library runs function that's not called -- magic!

**URL:** <https://forum.code.org/t/share-as-library-runs-function-thats-not-called-magic/33848>\
**Category:** Coding and Debugging Help\
**Created:** [December 7, 2020, 4:32pm UTC](https://forum.code.org/t/share-as-library-runs-function-thats-not-called-magic/33848 "2020-12-07T16:32:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael\_hobson](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/michael_hobson/32/4191_2.png) [@michael\_hobson](https://forum.code.org/u/michael_hobson)\
**Post date:** [December 7, 2020, 4:32pm UTC](https://forum.code.org/t/share-as-library-runs-function-thats-not-called-magic/33848/1 "2020-12-07T16:32:54Z")

</div>

I believe App Lab is glitching due to the Share as Library feature. Here is what is happening, [you can experience it here](https://studio.code.org/projects/applab/dhBxa8jhH5L-uXMbxe1kCy_S2eL_VlTIEAdf_0_DHLk).

1. I created a (very silly) function and tested it with 2 console.logs. Both ran successfully.
2. I shared the function as a library using the Share as Library feature.
3. I ran the function again, without changing it, and it ran 4 times.
4. I commented out my console.logs, the function still ran 2 times even though my code was not calling it.
5. I deleted my console.logs, the function still runs 2 times even though it is not being called.

---

<div class="post-metadata">

**Author:** ![michael\_hobson](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/michael_hobson/32/4191_2.png) [@michael\_hobson](https://forum.code.org/u/michael_hobson)\
**Post date:** [December 7, 2020, 5:10pm UTC](https://forum.code.org/t/share-as-library-runs-function-thats-not-called-magic/33848/2 "2020-12-07T17:10:13Z")

</div>

Further investigation shows that Share as Library included the function calls with the function code, even though they were above the function definition and comments, separated by a blank line.

So the problem seems to be that Share as Library is grabbing more than simply the function and documentation.

I resolved the issue but worry that the Share as Library behavior may still occur.

---

<div class="post-metadata">

**Author:** ![gjschmidt](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gjschmidt/32/4922_2.png) [@gjschmidt](https://forum.code.org/u/gjschmidt)\
**Post date:** [December 7, 2020, 10:45pm UTC](https://forum.code.org/t/share-as-library-runs-function-thats-not-called-magic/33848/3 "2020-12-07T22:45:26Z")

</div>

I’m glad you were able to resolve your issue. If you think there is a bug in Share as Library, please send an email to [support@code.org](mailto:support@code.org) and be share to include a link to the code.
