Skip to content

Commit

Permalink
Fix for RPC memory leak (#1044)
Browse files Browse the repository at this point in the history
* Clear current invocation once resolved
* Interfaces may not be registered -- unauthorized access or tests scenarios -- so try/catch

(cherry picked from commit 777c9bd)
  • Loading branch information
swbsi authored and mergify-bot committed Mar 30, 2021
1 parent d92e00b commit ab49944
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/imodeljs-common",
"comment": "Memory leak fix",
"type": "none"
}
],
"packageName": "@bentley/imodeljs-common",
"email": "69857376+swbsi@users.noreply.github.com"
}
7 changes: 7 additions & 0 deletions core/common/src/rpc/core/RpcInvocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ export class RpcInvocation {
interfaceName: (typeof (this.operation) === "undefined") ? "" : this.operation.interfaceDefinition.interfaceName,
};

try {
const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;
if (impl[CURRENT_INVOCATION] === this) {
impl[CURRENT_INVOCATION] = undefined;
}
} catch (_err) { }

return fulfillment;
}

Expand Down

0 comments on commit ab49944

Please sign in to comment.