diff --git a/service/history/replication/raw_task_converter.go b/service/history/replication/raw_task_converter.go index 6caf0a0ed47..fe892eebf45 100644 --- a/service/history/replication/raw_task_converter.go +++ b/service/history/replication/raw_task_converter.go @@ -116,8 +116,15 @@ func (c *SourceTaskConverterImpl) Convert( if clientShardID != c.clientShardKey.ShardID { return nil, nil } + var ctx context.Context + var cancel context.CancelFunc + + if namespaceEntry != nil { + ctx, cancel = newTaskContext(namespaceEntry.Name().String()) + } else { + ctx, cancel = context.WithTimeout(context.Background(), applyReplicationTimeout) + } - ctx, cancel := newTaskContext(namespaceEntry.Name().String()) defer cancel() replicationTask, err := c.historyEngine.ConvertReplicationTask(ctx, task) if err != nil {