async handleOnce()

in src/Runtime/Runtime.ts [62:91]


  async handleOnce(): Promise<void> {
    const { bodyJson, headers } = await this.client.nextInvocation();
    const invokeContext = new InvokeContext(headers);
    invokeContext.updateLoggingContext();

    const [callback, callbackContext] = CallbackContext.build(
      this.client,
      invokeContext.invokeId,
      this.scheduleIteration.bind(this)
    );

    try {
      this._setErrorCallbacks(invokeContext.invokeId);
      this._setDefaultExitListener(invokeContext.invokeId);

      const result = this.handler(
        JSON.parse(bodyJson),
        invokeContext.attachEnvironmentData(callbackContext),
        callback
      );

      if (_isPromise(result)) {
        result
          .then(callbackContext.succeed, callbackContext.fail)
          .catch(callbackContext.fail);
      }
    } catch (err) {
      callback(err);
    }
  }