Ensure last transaction handling will not make the Status notification failing
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -799,6 +799,7 @@ export default class OCPPService {
const lastTransaction = await TransactionStorage.getLastTransactionFromChargingStation(
tenant, chargingStation.id, connector.connectorId, { withUser: true });
if (lastTransaction) {
+ try {
// Transaction completed
if (lastTransaction.stop) {
// Check Inactivity
@@ -820,7 +821,7 @@ export default class OCPPService {
await Logging.logWarning({
...LoggingHelper.getChargingStationProperties(chargingStation),
tenantID: tenant.id,
- module: MODULE_NAME, method: 'checkAndUpdateLastCompletedTransaction',
+ module: MODULE_NAME, method: 'checkAndUpdateLastCompletedTransactionFromStatusNotification',
action: ServerAction.OCPP_STATUS_NOTIFICATION,
message: `${Utils.buildConnectorInfo(lastTransaction.connectorId, lastTransaction.id)} Received Status Notification '${statusNotification.status}' while a transaction is ongoing`,
detailedMessages: { statusNotification }
@@ -828,6 +829,16 @@ export default class OCPPService {
}
// Clear Connector Runtime Data
OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, lastTransaction.connectorId);
+ } catch (error) {
+ await Logging.logWarning({
+ ...LoggingHelper.getTransactionProperties(lastTransaction),
+ tenantID: tenant.id,
+ module: MODULE_NAME, method: 'checkAndUpdateLastCompletedTransactionFromStatusNotification',
+ action: ServerAction.OCPP_STATUS_NOTIFICATION,
+ message: `${Utils.buildConnectorInfo(lastTransaction.connectorId, lastTransaction.id)} Error while trying to update the last Transaction`,
+ detailedMessages: { error: error.stack, statusNotification, lastTransaction }
+ });
+ }
}
}
}

Ensure last transaction handling will not make the Status notification failing