-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LIT-2333] Add e2e test for initializing multiple clients #331
[LIT-2333] Add e2e test for initializing multiple clients #331
Conversation
This commit removes the following global variables: logManager, logger, litConfig, litNodeClient
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you removed methods which we where using in many packages. Can you outline the implications and behavior changes that are introduced with these utilities gone? #331 will also add many of these methods. back when merged. There does not seem to be a path forward for the above mentioned pr with the current implementation.
While removing the implementations which utilize the global state does make a path forward, I am unsure what this pr recommends as a migration from the previous implementations.
if (!client.ready) { | ||
return fail('client not ready'); | ||
} | ||
if (client.config.litNetwork !== network) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a check on globalThis
to assert on the new global namespacing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't implement the global namespacing, I think it's a risky approach (see also #331 (comment)). There could be a use case for global namespaces I'm not aware of yet: in that case please let me know.
@@ -60,7 +60,6 @@ export class LitAuthClient { | |||
*/ | |||
constructor(options?: LitAuthClientOptions) { | |||
this.providers = new Map(); | |||
bootstrapLogManager('auth-client'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did we remove this line?
packages/misc/src/lib/misc.ts
Outdated
import { version } from '@lit-protocol/constants'; | ||
|
||
const logBuffer: Array<Array<any>> = []; | ||
const defaultLogger = LogManager.Instance.get('lit-sdk'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this be a global logger? I would like to keep the package names as categories if possible. Open to discussion however.
Also why did you remove the buffer which allows us to collect logs when we are not in a connected
state?
packages/misc/src/lib/misc.ts
Outdated
if (!globalThis) { | ||
// there is no globalThis, just print the log | ||
console.log(...args); | ||
return; | ||
} | ||
|
||
// check if config is loaded yet | ||
if (!globalThis?.litConfig) { | ||
// config isn't loaded yet, push into buffer | ||
logBuffer.push(args); | ||
return; | ||
} | ||
|
||
if (globalThis?.litConfig?.debug !== true) { | ||
return; | ||
} | ||
// config is loaded, and debug is true | ||
|
||
// if there are there are logs in buffer, print them first and empty the buffer. | ||
while (logBuffer.length > 0) { | ||
const log = logBuffer.shift() ?? ''; | ||
globalThis?.logger && | ||
globalThis.logManager.get(globalThis.logger.category).error(...log); | ||
} | ||
|
||
globalThis?.logger && | ||
globalThis.logManager.get(globalThis.logger.category).error(...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove all of these utilities?
This reverts commit 14f35f0.
@joshLong145 I updated the PR so that it only adds the e2e test for connecting to multiple networks. The test passes with the code as is. To be clear, with the code as it is, creating multiple clients does mess up the global state (
There is one more check to do: making sure that there are no conflicts with the usage of |
@cairomassimo can we close this pr since we no longer need to make code changes? |
@joshLong145 It's not much, but we can merge it so we have the new e2e test case? I'm making it "ready for review" just in case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with having this for our e2e tests
* make capacityDelegationAuthSig optional (#337) * Ref/run sev att check on mainnets (#339) * add sev snp att check by default on main nets * fmt * [LIT-2333] Add e2e test for initializing multiple clients (#331) * Remove globals for loggers and client This commit removes the following global variables: logManager, logger, litConfig, litNodeClient * Test e2e parallel connections to multiple networks * Revert "Remove globals for loggers and client" This reverts commit 14f35f0. * Cleanup/logger (#332) * aggregate logs under categories. allow for cross category tracing * autogen * fmt * change log persistence to use request id's as keys for lookup * fmt * fmt * fix logger creation * fmt * fmt * Update/test token (#336) * update token symbol * fmt * fmt * fmt * fix: rm console.log (#342) * Fix logging tests in 3.1.2 staging (#343) * fix logging tests * fix category in test * Published version: 3.1.2 --------- Signed-off-by: Anson <[email protected]> Co-authored-by: Bean <[email protected]> Co-authored-by: Massimo Cairo <[email protected]>
Description
This PR enables the use of multiple instances of
LitNodeClient
, in order to connect to different networks in the same application, at the same time.This was achieved by removing the global variables
litConfig
,litNodeClient
,logger
andlogManager
and their references.Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
.connect()
on multiple clients.Checklist: