-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: always return same object from client prop (#18)
* fix: Can await returned client calling `await client` was throwing an error. The returned client should not be thenable, and should just return the same client * fix: always return same object from client prop There was a bug where every time you access a client property e.g. `client.namespace` it would return a new Proxy object, which would lead to unexpected behaviour when accessing a client object, e.g. `client.namespace === client.namespace` would be false. It would also cause a lot of garbage collection slowing things down (all those Proxy objects need to be garbage collected). This fix caches all the sub clients that are created when you access properties. This could be seen as a memory leak because every time you access a client property, the value is cached, but this is effectively lazily building the API on the server side - as long as you don't call huge numbers of non-existent properties on the client it won't take much more memory than the server-side API.
- Loading branch information
1 parent
7451dc3
commit 8517f2f
Showing
2 changed files
with
42 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters