code: function onServerPreHandler (ctx, err, value) {
    if (err) {
      if (err instanceof SuperError) {
        ctx._response.error = err.rootCause || err.cause || err;
      } else {
        ctx._response.error = err;
      }
  
      const internalError = new Errors.MostlyError(
          Constants.EXTENSION_ERROR, ctx.errorDetails).causedBy(err);
      ctx.log.error(internalError);
  
      return ctx.finish();
    }
  
    // reply value from extension
    if (value) {
      ctx._response.payload = value;
      return ctx.finish();
    }
  
    try {
      let action = ctx._actMeta.action.bind(ctx);
  
      // execute add middlewares
      ctx._actMeta.dispatch(ctx._request, ctx._response, (err) => {
        // middleware error
        if (err) {
          if (err instanceof SuperError) {
            ctx._response.error = err.rootCause || err.cause || err;
          } else {
            ctx._response.error = err;
          }
  
          let internalError = new Errors.MostlyError(
              Constants.ADD_MIDDLEWARE_ERROR, ctx.errorDetails).causedBy(err);
          ctx.log.error(internalError);
  
          return ctx.finish();
        }
  
        // if request type is 'pubsub' we dont have to reply back
        if (ctx._request.payload.request.type === Constants.REQUEST_TYPE_PUBSUB) {
          action(ctx._request.payload.pattern);
          return ctx.finish();
        }
  
        // execute RPC action
        if (ctx._actMeta.isPromisable) {
          action(ctx._request.payload.pattern)
            .then(x => ctx._actionHandler(null, x))
            .catch(e => ctx._actionHandler(e));
        } else {
          action(ctx._request.payload.pattern, ctx._actionHandler.bind(ctx));
        }
      });
    } catch (err) {
      if (err instanceof SuperError) {
        ctx._response.error = err.rootCause || err.cause || err;
      } else {
        ctx._response.error = err;
      }
  
      // service should exit
      ctx._shouldCrash = true;
  
      ctx.finish();
    }
  }
docs: Is called before the server action is executed