-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Is there an existing issue for this?
- I have searched the existing issues
SDK version
Using Lit JS SDK at commit 412264b and beyond (master / branches after PR #579 ).
Lit Network
Datil / or whichever network you’re using (if applicable).
Description of the bug/issue
After the refactoring in PR #579 , the LogLevel enum was supposed to be replaced by LOG_LEVEL constants from @lit-protocol/constants. However, subsequent merges caused a partial rollback (ancestor revert):
- Commit: Merge branch 'master' into staging/v7 on Oct 3, 2024, reintroduced
LogLevelreferences while also removingexport { LOG_LEVEL };inlogger.ts. - This mismatch led to failing tests (TypeScript errors and incorrect timestamp comparisons), as well as confusion around whether
LogLevelorLOG_LEVELshould be used.
Currently logger test fails with the error
npx nx run logger:test --coverage
:
FAIL logger packages/logger/src/lib/logger.spec.ts
● Test suite failed to run
packages/logger/src/lib/logger.spec.ts:1:10 - error TS2724: '"./logger"' has no exported member named 'LOG_LEVEL'. Did you mean 'LogLevel'?
1 import { LOG_LEVEL, LogManager } from './logger';We want to keep the code aligned with the overall project direction—to unify everything under LOG_LEVEL—but also maintain backwards compatibility in the short term (e.g., ensuring both LogLevel and LOG_LEVEL references don’t break the build).
Severity of the bug
Medium: The logger tests fail out-of-the-box, causing confusion and blocking straightforward usage or contributions in the logger package.
Steps To Reproduce
- In this environment (Node.js v20, Nx 17.x, etc.), check out the
masterorstaging/v7branch at or after commitc8801c5fe87cacee7.... - Run
npx nx run logger:test --coverageoryarn tools --test --unit(depending on your setup). - See TypeScript errors:
npx nx run logger:test --coverage
:
FAIL logger packages/logger/src/lib/logger.spec.ts
● Test suite failed to run
packages/logger/src/lib/logger.spec.ts:1:10 - error TS2724: '"./logger"' has no exported member named 'LOG_LEVEL'. Did you mean 'LogLevel'?
1 import { LOG_LEVEL, LogManager } from './logger';Or find that tests referencing LogLevel fail if the code exports only LOG_LEVEL, etc.
Link to code
- Refactoring: PR #579
- Commit where rollback occurred: c8801c5fe87cacee7... (Oct 3, 2024)
- File:
packages/logger/src/lib/logger.tsandpackages/logger/src/lib/logger.spec.tshttps://github.com/LIT-Protocol/js-sdk/blob/master/packages/logger/src/lib/logger.spec.ts#L1
Anything else?
Proposed fix
- Reintroduce
export { LOG_LEVEL }inlogger.ts, ensuring backward compatibility for any remaining references toLogLevel. - Update the tests to consistently use
LOG_LEVEL.DEBUG(etc.) instead ofLogLevel.DEBUG, or vice-versa if the old enum is still needed. - Ultimately unify everything under
LOG_LEVELper the original refactor’s intent.
Context
- I tested a local branch that modifies
logger.spec.tsto rely fully onLOG_LEVEL, while still exporting bothLOG_LEVELandLogLevelfor backward compatibility. - After these changes,
npx nx run logger:test --coveragepasses with no TS errors and the test that checks creation timestamps is fixed to compare numeric vs. string properly.