Skip to content
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

[SM-1384] Fix panic on re-registering logger | WASM #935

Merged
merged 6 commits into from
Sep 12, 2024
Merged

Conversation

Thomas-Avery
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/SM-1384

📔 Objective

When creating multiple WASM clients, a panic occurs failed to initialize logger: SetLoggerError()).

Looks to be the same thing we fixed:
#181
#676

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@Thomas-Avery Thomas-Avery requested review from Hinton, dani-garcia and a team August 2, 2024 22:22
@Thomas-Avery Thomas-Avery self-assigned this Aug 2, 2024
Copy link
Contributor

github-actions bot commented Aug 2, 2024

Logo
Checkmarx One – Scan Summary & Detailsb7817415-93cd-4073-8392-535aed965882

No New Or Fixed Issues Found

Copy link

codecov bot commented Aug 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 58.45%. Comparing base (ac0e029) to head (c2cc8e1).
Report is 52 commits behind head on main.

Files with missing lines Patch % Lines
crates/bitwarden-wasm/src/client.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #935   +/-   ##
=======================================
  Coverage   58.45%   58.45%           
=======================================
  Files         194      194           
  Lines       13358    13357    -1     
=======================================
  Hits         7808     7808           
+ Misses       5550     5549    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

dani-garcia
dani-garcia previously approved these changes Aug 5, 2024
mzieniukbw
mzieniukbw previously approved these changes Aug 13, 2024
console_log::init_with_level(convert_level(log_level.unwrap_or(LogLevel::Info)))
{
panic!("failed to initialize logger: {:?}", e);
warn!("Logger already initialized, log level will not be changed.");
Copy link
Member

Choose a reason for hiding this comment

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

It's probably going to be confusing to get a warning when you setup multiple sdk clients. If we do want to warn about this we should check if the log level is different.

Copy link
Contributor Author

@Thomas-Avery Thomas-Avery Aug 15, 2024

Choose a reason for hiding this comment

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

Agreed, at the time of looking at the console_log crate, I didn't think it was possible.

After further research, I found out we can use the log crate functions, and we can just set the level.

Thoughts on this approach?

https://docs.rs/log/0.4.22/log/fn.set_max_level.html

Edit here 3a86e8e

Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

Seems reasonable. Do we need to update the other bindings with similar behaviour?

@coltonhurst
Copy link
Member

As discussed with the SM team, merging this. QA will handle testing on main prior to the future release.

@coltonhurst coltonhurst merged commit b00d337 into main Sep 12, 2024
59 of 61 checks passed
@coltonhurst coltonhurst deleted the sm/sm-1384 branch September 12, 2024 18:53
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.

5 participants