App A is set up as a dependency for App B and a component from App A is used in App B which uses server side code to validate something. While loading App B the component is failing with the error message of 'module not found" for server side code. How can server code be shared between applications. The documentation does not talk about how to share server code between apps, like it describes how to share forms (as components) and data tables between apps.
Hi @alexri and welcome to the Forum!
Here’s a simple example of apps sharing server-side code:
Main app + dependency:
https://anvil.works/build#clone:MK4J4VKLWEJFIBN2=RM2V6Z7WITXNRPGOKCKYT35L
Dependency only:
https://anvil.works/build#clone:KIXZ3D57PJTVL6TU=GCSZAACVUTFJ6FGIYWPGBDY2
Clicking the button in the main app sends the text in the TextBox to the server code in the dependency app for validation.
I’m also happy to take a look at your apps for you - could you send over a clone link? If you can strip your apps down to something simple that has the problem but doesn’t reveal any sensitive data, that would be really helpful
Hi @bridget For some reason when I clone your app it shows the dependency as deleted app. So I went ahead and renamed the app and recreated the dependency. However now when I run the main app I am getting the following error
anvil.server.StackOverflow: Too many nested anvil.server.call()s
at ServerModule1, line 14
called from /libanvil/anvil_downlink_worker/init.py, line 53
called from , line 626
Here are link to the two apps:
Library app:
https://anvil.works/build#clone:PP6F2IWNZRXXC2FI=5Q6GF5BJS7CGSPYXNC7CG546
Main App
https://anvil.works/build#clone:2LL3B6RGQEBVXQJC=ARLOB2LGCNXXWKJRDYUIBN3K
Hi @alexri if you try again - I’ve edited the post so you can download the dependency and the app at the same time and should resolve the deleted dependency problem.
regarding your specific error after you made changes… it’s because you’re doing
anvil.server.call('return_validation_errors')
from inside your server function - you must have added this when you were making changes…