a) Am I allowed to perform other operations that take longer than 5s?
E.g., some postprocessing of queried data and then return to the user
later on?
I think the 5s limitation can't be breached so far.As @Mark mentioned in the comment and follow my previous case:Delete Documents from Cosmos using Query without Partition Key Specification procedures are best suited for operations that are write-heavy,not read or delete heavy,even long time execution of API.
b) Do I pay RUs only for the actual database operations within a
stored procedure or also for some kind of "JavaScript execution time"
as well?
Based on the Cosmos DB pricing page, cost is only affected by Storage Capacity and throughput.In fact, any operations are based on the REST API,even for JS Server features here. So,i think you don't need to pay more for JS execution time.
Update Answer:
If i don't misunderstanding here,you access cosmos db for a single query in the SP and then do more workloads which have nothing with cosmos db. You just wonder if this scenario costs you more,in other words,you can use the most of the resources allocated to you by SP.
Per my research,no any special billing policy for SP.So, everything is determined by RUs.For your scenario,maybe you could calculate RUs of SP with or without custom code to compare them.
StoredProcedureResponse response = documentClient.executeStoredProcedure(collectionLink + "/sprocs/test", requestOptions, null);
System.out.println(response.getRequestCharge());