Skip to content

Commit

Permalink
fix(OSP/JS/Web): Time out waiting for a servlet script to become avai…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
obiltschnig committed Feb 9, 2024
1 parent 98a0b9c commit 11615aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions platform/OSP/JS/Web/src/JSServletExecutorCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class JSServletExecutorHolder
_mutex.lock();
}

void lock(long timeout)
{
_mutex.lock(timeout);
}

void unlock()
/// Unlocks access to the instance.
{
Expand Down
11 changes: 10 additions & 1 deletion platform/OSP/JS/Web/src/JSServletFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ void JSServletFilter::process(Poco::Net::HTTPServerRequest& request, Poco::Net::
if (pExecutorHolder)
{
cacheLock.unlock();
Poco::ScopedLock<JSServletExecutorHolder> lock(*pExecutorHolder);
long timeout = pBundle->properties().getUInt32("osp.js.jssTimeout"s, 30000);
Poco::ScopedLock<JSServletExecutorHolder> lock(*pExecutorHolder, timeout);
pExecutorHolder->executor()->prepareRequest(request, response);
pExecutorHolder->executor()->handleRequest(request, response);
}
Expand Down Expand Up @@ -127,6 +128,14 @@ void JSServletFilter::process(Poco::Net::HTTPServerRequest& request, Poco::Net::
sendErrorResponse(response, "Script execution failed. See the server log for details."s);
}
}
catch (Poco::TimeoutException& exc)
{
_pContext->logger().error("Request timed out waiting for servlet script %s to become available."s, request.getURI());
if (!response.sent())
{
sendErrorResponse(response, "The request timed out waiting for the script to become available. See the server log for details."s);
}
}
catch (Poco::Exception& exc)
{
_pContext->logger().log(exc);
Expand Down

0 comments on commit 11615aa

Please sign in to comment.