Hi guys, I am trying to find out how to catch the error by using fromObservable. In following example my getTariffById just throw an error, but it seems like the machine come to the done state anyway. It seems obvious that the fromPromise is the best candidate here to use instead of fromObservable, but I cannot use it with Temporal Workflow because fromObservable use AbortController under the hood, which is not defined in Temporal Workflow. Can we achive same result and error handling with fromObservable in this machine?
types: {
context: {},
},
actors: {
fetchTariff: fromObservable(() =>
from(getTariffById(tariffId)).pipe(
map((response) => {
// Process the response
console.log("Data received:", response);
return response;
}),
catchError((error) => {
// Handle errors
console.error("Error:", error);
return of({ error: true, message: error.message });
})
)
),
},
}).createMachine({
context: {
user: null,
tariff: null,
},
id: "CreateCheckoutSession",
initial: "fetching",
states: {
fetching: {
invoke: {
input: {},
onDone: {
target: "done",
},
onError: {
target: "error",
},
src: "fetchTariff",
},
},
done: {},
error: {},
},
});
const actor = createActor(machine);
actor.start();