Skip to content

fix: Improve logging when not initialized#410

Merged
roncohen merged 3 commits intomainfrom
improve-init-logging
May 15, 2025
Merged

fix: Improve logging when not initialized#410
roncohen merged 3 commits intomainfrom
improve-init-logging

Conversation

@roncohen
Copy link
Contributor

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.

@roncohen roncohen requested review from Copilot and pavkam May 15, 2025 11:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 secretKey validation 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 initializationFinished to isInitialized to 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) {

@roncohen roncohen enabled auto-merge May 15, 2025 11:32
@roncohen roncohen added this pull request to the merge queue May 15, 2025
Merged via the queue into main with commit e948217 May 15, 2025
6 checks passed
@roncohen roncohen deleted the improve-init-logging branch May 15, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants