This issue has been reported here and has been closed. I do see that there is currently a problem with publishing scripts as a service. Previously published scripts work fine but not able to publish new scripts as a service.
When the service URL is put into a browser, the following error is shown
Google Docs has encountered a server error. If reloading the page doesn’t help, please >contact us.
To discuss this or other issues, visit the Google Docs Help forum. To see the list of >known problems, check the Google Docs Known Issues page.
Sorry, and thanks for your help!
– The Google Docs Team
The Apps Script dashboard shows all services as running ok.
One such example is https://docs.google.com/macros/exec?service=AKfycbypKC46e9mIpPerpki3iNfWYJb0IPnKLXq16IOJag
I was able to publish other scripts as a service without issues.
The problem seems to have been resolved. I’m not seeing the error anymore for the same script.
The code itself isn’t great
When I had the problem, the problem wasn’t seen for every script I created. One of the scripts randomly had this error showing up.