Operation cannot be performed on an inactive dataset

It seems like once again, even after being in the last TMS Web Core release, some datasets can't be opened.

im getting:

Uncaught [object Object] | FMessage::CompIdFromJWTDataset : Operation cannot be performed on an inactive dataset FHelpContext::0 FJSError::Error: CompIdFromJWTDataset : Operation cannot be performed on an inactive dataset FStack::Error:

from:

function TDataModule1.CompIdFromJWT(): string;
begin
ConnectionCompIdFromJWT.Active := True;

CompIdFromJWTDataset.First;
if Assigned(CompIdFromJWTDataset.FieldByName('value')) then
begin
WriteLn(CompIdFromJWTDataset.FieldByName('value').Text);
Result:= CompIdFromJWTDataset.FieldByName('value').Text;
end;
end;

What dataset component are you using?

TWebClientDataset

do you set the data before making it active or are you trying to open an empty dataset?

I try to open it after the connection is finished, with the AfterOpen event.

Sounded like you expect the AfterOpen to run "between" those 2 lines. But isn't it all asynchronous ? Isn't this .First running before the Dataset is really open?

The AutoOpenDataset property is set to True,

Ok, but it's asynchronous. It's not safe to use WebClientDataSet.First inmediatelly after WebClientConnection.Active := True.
Please see page 596 of Webcore Developers Guide:

When WebClientConnection.AutoOpenDataSet = true, the WebClientConnection will automatically open the dataset after this, making it ready to put data in connected DB-aware controls. A typical flow to connect to data, fetch it and then using the dataset directly from code is:

procedure TForm1.WebButton1Click(Sender: TObject); 
begin 
  // start the asynchronous process to perform a HTTP GET request to retrieve the data  
  WebClientConnection1.Active := true; 
end; 

procedure TForm1.WebClientConnection1AfterConnect(Sender: TObject); 
begin 
  // Data was retrieved in OnAfterConnect, dataset was automatically opened by the  
  // WebClientConnection and ready for use 
  WebClientDataSet1.First; 
  while not WebClientDataSet1.Eof do 
    begin 
      WebListbox1.Items.Add(WebClientDataSet1.FieldByName('email').AsString); 
      WebClientDataSet1.Next; 
    end; 
end;

Have you tried putting this code in the AfterOpen event?

CompIdFromJWTDataset.First;
if Assigned(CompIdFromJWTDataset.FieldByName('value')) then
begin
WriteLn(CompIdFromJWTDataset.FieldByName('value').Text);
Result:= CompIdFromJWTDataset.FieldByName('value').Text;
end;