appback-remoteagent 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -179,10 +179,16 @@ export class BotPollingStateService {
|
|
|
179
179
|
const state = await this.read();
|
|
180
180
|
state.updatedAt = new Date().toISOString();
|
|
181
181
|
const tmpPath = `${this.filePath}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;
|
|
182
|
-
this.writeInFlight = this.writeInFlight.then(async () => {
|
|
182
|
+
this.writeInFlight = this.writeInFlight.catch(() => undefined).then(async () => {
|
|
183
183
|
await fs.mkdir(path.dirname(this.filePath), { recursive: true });
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
try {
|
|
185
|
+
await fs.writeFile(tmpPath, `${JSON.stringify(state, null, 2)}\n`, "utf8");
|
|
186
|
+
await fs.rename(tmpPath, this.filePath);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
await fs.rm(tmpPath, { force: true }).catch(() => undefined);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
186
192
|
});
|
|
187
193
|
await this.writeInFlight;
|
|
188
194
|
}
|