Fix unhandled rejection on RCON lost (#580)

When using .finally on a promise a new promise is created which calls
the handler passed to it when the the original promise is resolved or
rejected, and resolves or rejects with same value as the original
promise.  This means if the rejection of the new promise that was
created by finally is not handled then an unhandled promise rejection
will be raised.

Fix by making sure the promise rejection from the finally promise
created in subspace_storage's handleUpdateStorageEvent is properly
handled.
This commit is contained in:
Hornwitser authored and GitHub committed 2024-02-05 15:51:15 +01:00
1 parent c2b6a6e1c0
commit 520007c8d1
2 files changed
+8 -2

No files matched your search

+7
View File
@@ -1,5 +1,12 @@
# Changelog
## Version 2.0.0-alpha.17
## Changes
- Fixed an unhandled error in Subspace Storage crashing the host.
## Version 2.0.0-alpha.16
## Changes
+1 -2
View File
@@ -116,7 +116,6 @@ export class InstancePlugin extends BaseInstancePlugin {
let itemsJson = lib.escapeString(JSON.stringify(items));
let task = this.sendRcon(`/sc __subspace_storage__ UpdateInvData("${itemsJson}")`, true);
this.pendingTasks.add(task);
task.finally(() => { this.pendingTasks.delete(task); });
await task;
await task.finally(() => { this.pendingTasks.delete(task); });
}
}