title: AWS Step Functions Activity Worker not seeing execution when worker was stopped
body: <h3>Version of AWS SDK for Go?</h3>
  
  <p>v2.0.0-preview.3</p>
  
  <h3>Version of Go (<code>go version</code>)?</h3>
  
  <p>go1.9.3 darwin/amd64</p>
  
  <h3>What issue did you see?</h3>
  
  <p>I'm writing an Activity Worker for Step Functions in Go. </p>
  
  <p>When:</p>
  
  <ul>
  <li>The activity worker is running, </li>
  <li>Then, we start a workflow execution from the SFN console</li>
  </ul>
  
  <p>Everything appears to be working fine.</p>
  
  <p>However, when:</p>
  
  <ul>
  <li>The activity worker is stopped,</li>
  <li>Then, we start a workflow execution from the SFN console, </li>
  <li>Then the worker is started back up, </li>
  </ul>
  
  <p>The worker appears to poll SFN but it does not execute tasks initiated during the time it was stopped. 
  If we start a new workflow execution at this point (while the worker is running), the worker performs the new task successfully. The workflows executed during the time the worker was stopped is not being picked up by the worker.</p>
  
  <p>EDIT: Looking at the execution history, I see the Timed Out status and the following event log:</p>
  
  <p><a href="https://i.stack.imgur.com/EZpfz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EZpfz.png" alt="enter image description here"></a></p>
  
  <h3>Steps to reproduce</h3>
  
  <p>Here if my SFN state machine:</p>
  
  <pre><code>{
    "Comment": "An example using a Task state.",
    "StartAt": "getGreeting",
    "Version": "1.0",
    "TimeoutSeconds": 300,
    "States":
    {
      "getGreeting": {
        "Type": "Task",
        "Resource": "arn:aws:states:ap-southeast-1:196709014601:activity:get-greeting",
        "End": true
      }
    }
  }
  </code></pre>
  
  <p>Here is my SFN worker:</p>
  
  <pre><code>package main
  
  import (
      "github.com/aws/aws-sdk-go-v2/aws"
      "github.com/aws/aws-sdk-go-v2/aws/endpoints"
      "github.com/aws/aws-sdk-go-v2/aws/external"
      "github.com/aws/aws-sdk-go-v2/service/sfn"
      "fmt"
      "encoding/json"
  )
  
  type Worker struct {
      svc             *sfn.SFN
      activityARN     string
  }
  
  type Task struct {
      input   *string
      token   *string
  }
  
  func New(activityARN string) *Worker {
      cfg, err := external.LoadDefaultAWSConfig()
      if err != nil {
          panic("unable to load SDK config, " + err.Error())
      }
      // Set the AWS Region that the service clients should use
      cfg.Region = endpoints.ApSoutheast1RegionID
  
      // Using the Config value, create the Step Functions client
      svc := sfn.New(cfg)
  
      w := &amp;Worker{
          svc: svc,
          activityARN: activityARN,
      }
      return w
  }
  
  func (w *Worker) getTask() *Task {
      req := w.svc.GetActivityTaskRequest(&amp;sfn.GetActivityTaskInput{
          ActivityArn: aws.String(w.activityARN),
      })
      res, err := req.Send()
      if err != nil { fmt.Println("failed to get tasks, "+err.Error()) }
      return &amp;Task{
          input: res.Input,
          token: res.TaskToken,
      }
  }
  
  // Call SendTaskSuccess on success
  func (w *Worker) handleSuccess(taskToken *string, json *string) error {
      req := w.svc.SendTaskSuccessRequest(&amp;sfn.SendTaskSuccessInput{
          TaskToken: taskToken,
          Output: json, // JSON string
      })
      _, err := req.Send()
      if err != nil { fmt.Println("failed to send task success result, "+err.Error()) }
      return err
  }
  
  // Call SendTaskFailure on error
  func (w *Worker) handleFailure(taskToken *string, err error) error {
      errorMessage := err.Error()
      req := w.svc.SendTaskFailureRequest(&amp;sfn.SendTaskFailureInput{
          TaskToken: taskToken,
          Error: &amp;errorMessage,
      })
  
      _, err = req.Send()
      if err != nil { fmt.Println("failed to send task failure result, "+err.Error()) }
      return err
  }
  
  func main() {
      activityARN := "arn:aws:states:ap-southeast-1:196709014601:activity:get-greeting"
      worker := New(activityARN)
  
      fmt.Println("Starting worker")
      for {
          // 1. Poll GetActivityTask API for tasks
          fmt.Println("Polling for tasks")
          task := worker.getTask()
          if task.token == nil { continue }
  
          // 2. Do some actual work
          fmt.Println("Working")
          result, err := work(task.input)
  
          // 3. Notify SFN on success and failure
          fmt.Println("Sending results")
          if err == nil {
              worker.handleSuccess(task.token, result)
          } else {
              worker.handleFailure(task.token, err)
          }
      }
  }
  
  // Handles marshalling and un-marshalling JSON
  func work(jsonInput *string) (*string, error) {
      input := &amp;GreetInput{}
      json.Unmarshal([]byte(*jsonInput), input)
  
      result, err := Greet(input) // Actual work
      if err != nil { return nil, err }
  
      outputBytes, _ := json.Marshal(result)
      output := string(outputBytes)
      return &amp;output, nil
  }
  
  // Actual handler code
  type GreetInput struct {
      Who string
  }
  
  type GreetOutput struct {
      Message string
  }
  
  func Greet(input *GreetInput) (*GreetOutput, error) {
      message := fmt.Sprintf("hello %s", input.Who)
      output := &amp;GreetOutput {
          Message: message,
      }
      fmt.Println(message)
      return output, nil
  }
  </code></pre>
  
  <p>To run:</p>
  
  <pre><code>go build worker.go &amp;&amp; ./worker
  </code></pre>