Hello @ishijima_tatsuki_1
Here are the answers to your questions about EPG provider transaction management:
## 1. How to “Discard” the Object {}
In JavaScript/TypeScript, “destroying” an object means letting it go out of scope {} or explicitly setting it to null/undefined so it becomes eligible for garbage collection. There is no explicit destroy() or abort() method.
let channelProvider = await getChannelLineupProvider();
try
{ await channelProvider.add(channels); await channelProvider.commit(); // Success path }
catch (error)
{ // Abort by discarding the object - don't call commit() channelProvider = null; // Let it be garbage collected // Transaction is automatically aborted throw error; }
## 2. How to Recreate the Object {}
After a commit() or abort (discard), get a fresh provider instance from the factory function:
// After commit or abort, create new instance
channelProvider = await getChannelLineupProvider();
The provider factory functions (like getChannelLineupProvider(), getProgramLineupProvider(), etc.) return new transactional instances.
## 3. Is There an Explicit Abort API? {}
No. The documentation explicitly states that abortion happens by “destroying” the object without calling commit(). This is intentional - simply don’t call commit() and let the object be garbage collected.
## Practical Pattern {}
async function syncChannels(channels) {
let provider = await getChannelLineupProvider();
try {
const failures = await provider.add(channels);
if (failures.length > 0) {
// Log failures to backend
await logFailuresToBackend(failures);
// Decision point: abort or partial commit
provider = null; // Abort transaction
throw new Error(`Failed to add ${failures.length} channels`);
}
await provider.commit();
} catch (error)
{ provider = null; // Ensure abort on any error throw error; }
}
The key insight: these providers use implicit transaction management through object lifecycle rather than explicit abort methods. Not calling commit() before the object is garbage collected = transaction abort.
Destroying the ChannelLineupProvider, ProgramLineupProvider, and LiveEventProvider objects without calling a commit aborts the transaction.-- Destroying the objects here means letting it go out of scope or setting them to null explicitly. There is not abort api but throwing an error and intentionally not calling commit for failed updates will abort the transaction.
Q: I want to ensure that failed updates do not leave partial data or lock the provider state. Any clarification on the lifecycle management of these objects would be greatly appreciated.
You can catch all failed updates and choose to continue adding remaining data or abort the transaction.
Here is an example of LiveEventProvider provider for the same
const live_events_page_2 = getLiveEventData(11, 20); const addLiveEventFailures_page_2 = await LiveEventProvider.add(live_events_page_2,); if (addLiveEventFailures_page_2.length > 0) { // TODO: You should catch all the failed live events information and push it to your backend to quickly resolve the issues with the live event data. console.error(`EpgSync - there are ${addLiveEventFailures_page_2.length} live events from page 2 which failed to be added`,); processAddLiveEventFailures(addLiveEventFailures_page_2); // TODO: You can choose to continue adding the remaining live events or abort the live event ingestion process. Calling throw Error will prevent commit from happening and discard the entire transaction, if you choose not to throw error then you can commit only successful updates. throw Error(// 'Abort the live event ingestion process due to invalid live event data in page 2',// ); } // Step 3: Commit the Live Event Lineup using LiveEventProvider.commit const total_live_event_failures = addLiveEventFailures_page_1.length + addLiveEventFailures_page_2.length; console.info( `EpgSync - total number of errored live events ${total_live_event_failures}`, ); // If any live events failed to add, and you did not abort the process when receiving those failure errors, // then you can update the latestVersion for the successfully added live events and send the information about // the failed live events back to your backend so they can be fixed before the next sync. await LiveEventProvider.commit(latestVersion);
Warm regards,
Ivy