fix: Improve logging when not initialized#410
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances client initialization logging and error messages without throwing exceptions, by tracking initialization state and improving diagnostics.
- Track initialization completion and log an error if methods are used before init
- Include offline mode context in the "Bucket initialized" info log
- Refine
secretKeyvalidation message and update tests to reflect new warn text
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/node-sdk/test/client.test.ts | Updated expected warning string to match code change |
| packages/node-sdk/src/client.ts | Added initializationFinished flag, enhanced logs, and refined error messages |
Comments suppressed due to low confidence (2)
packages/node-sdk/src/client.ts:130
- [nitpick] Consider renaming
initializationFinishedtoisInitializedto make it clear this is a boolean flag.
private initializationFinished = false;
packages/node-sdk/src/client.ts:967
- There's no unit test covering the branch where
getFeature(s)is called before initialization—add a test to verify the error log.
if (!this.initializationFinished) {
pavkam
approved these changes
May 15, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Correctly initializing the BucketClient can be a bit tricky. This should complain more loudly when it happens.
I considered and rejected the idea of throwing an error when this happens because incorrectly constructed initialization code may only break under high concurrency and thus only show up in production which could cause down time if we throw.